addSubview,frame和bounds
来源:互联网 发布:关于单片机的论文 编辑:程序博客网 时间:2024/06/08 07:28
先看代码:
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(100.0, 100.0, 300.0, 300.0)]; view1.backgroundColor = [UIColor grayColor]; [self.view addSubview:view1]; UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 100.0)]; view2.backgroundColor = [UIColor redColor]; [self.view addSubview:view2];
看看运行结果:
这个很简单没问题,做个对比而已。
将上面的代码修改如下:
// [self.view addSubview:view2]; [view1 addSubview:view2];
运行结果:
区别出来了,由于view1的位置为(100, 100, 300, 300),所以[view1 addSubview:view2]使得view2的位置发送了变化,view2的frame为(0, 0, 100, 100),因为addSubview时是以view1为参考坐标系add的,所以view2的frame是相对于view1的frame而言的。
最后上两张很久以前看过的关于frame和bounds的区别的图,做个笔记:
- addSubview,frame和bounds
- bounds和frame区别
- ios bounds 和 frame
- frame.bounds和center
- bounds和frame区别
- bounds和frame区别
- bounds 和frame区别
- frame 和 bounds 区别
- frame、bounds和center
- bounds和frame
- frame,bounds和center
- ios frame和bounds
- Frame和bounds详解
- frame 和 bounds IOS
- frame.center和bounds
- ios-frame和bounds
- iOS frame和Bounds 以及frame和bounds区别
- iOS 一一 frame和Bounds 以及frame和bounds区别
- Windows下USB磁盘开发系列四:SetupDiEnumDeviceInterfaces()返回ERROR_NO_MORE_ITEMS 259错误代码的原因
- 关于android导入工程时出现的@Override错误问题的解决<转>
- 四步破解保利威视,免费用视频托管
- 将Excel2003的xls格式文件转换为kml及gpx文件(ExcelToKml)
- V$MYSTAT、V$SESSTAT、V$SYSSTAT、V$STATNAME
- addSubview,frame和bounds
- VS2012常用快捷键,VS2010常用快捷键
- virtualbox MTK flash_tool下载慢的问题
- leetcode Distinct Subsequences
- sql中 inner join, left join, right join 用法
- 对于支持上传文件的手机浏览器出现的图片不能预览问题的解决办法
- linux中 likely与unlikely
- java线程同步最基本的示例
- 黑马程序员_Java基础2