UIView
設置邊框: view.layer.borderWith=2;
設置邊角類型:view.layer.cornerRedius=6;//圓角
查看視圖的bounds:NSLog(@"aView bounds %@",NSStringFromCGRect(aView.bounds));
查看視圖的Frame:NSLog(@"aView frame? %@",NSStringFromCGRect(aView.frame));
設置視圖背景顏色的深淺:
aView.backgroundcolor=[UIColor yellowColor];
aView.alpha=0.5;//alpha是一個CGFloat類型,取值范圍是0.0到1.0
超出父視圖范圍不能進行交互
解決方法:****.clipsToBounds=YES;//超出父視圖的截去
重要方法:
初始化視圖:initWithFrame:(CGRect)frame
添加視圖:addSubview
插入視圖:insertSubview:atIndex;
insertSubview:aboveSubview
insertSubview:belowSubview
整理視圖:bringSubviewToFront
sendSubviewToBack
exchangeSubviewAtIndex:withSubviewAtIndex
移除視圖:removeFromSuperview
eg:[****? removeFromSuperview];//將****從父視圖中移除
Tag屬性
相當于視圖的編號,能快速定位子視圖,最好大點(100)
eg:[zishitu? setTag:101];//定義子視圖的Tag屬性
UIView *search= [fushitu viewWithTag:101];//快速獲取Tag為101的子視圖
NSLog(@"search = %@",search);//查看子視圖的屬性