UIView

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);//查看子视图的属性

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容