美文网首页
【技巧】View的Frame与Bounds区别

【技巧】View的Frame与Bounds区别

作者: 狂暴火鸡 | 来源:发表于2015-08-06 14:17 被阅读1129次

摘自 ios view的frame和bounds之区别(位置和大小)

事例代码

  UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, 250)];  
  [view1 setBounds:CGRectMake(-20, -20, 280, 250)];
  view1.backgroundColor = [UIColor redColor];  
  [self.view addSubview:view1];//添加到self.view    

  UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];  
  view2.backgroundColor = [UIColor yellowColor];  
  [view1 addSubview:view2];//添加到view1上,[此时view1坐标系左上角起点为(-20,-20)]  

下图说明一切~


Paste_Image.png

相关文章

  • iOS纪录

    (1)View的Frame与Bounds区别 摘自 ios view的frame和bounds之区别(位置和大小)...

  • 考试题

    一、 1.frame与bounds的区别: (1) Frame: frame的view是在父视图的view坐标...

  • Swift学习总结1

    1.bounds 与 frame的区别: frame: view在父view坐标系统中的位置和大小。(参照点是,父...

  • 【技巧】View的Frame与Bounds区别

    摘自 ios view的frame和bounds之区别(位置和大小) 事例代码 下图说明一切~

  • iOS中View的位置和大小

    frame bounds center frame bounds center是View的属性,定义了View的位...

  • 面试题总结

    1、Frame和Bounds的区别? (图片摘抄网络,侵权删) frame: 该view在父view坐标系统中的位...

  • size和center、frame和bounds

    frame和bounds的区别 frame指的是:该view在父view坐标系统中的位置和大小。(参照点是父控件的...

  • 深入探究frame和bounds的区别以及setbounds使用

    深入探究frame和bounds的区别以及setbounds使用 深入探究frame和bounds的区别以及set...

  • 面试题:frame和bounds的区别

    frame和bounds的区别在于其参考的坐标系不同。一个view的frame是指view在其父视图坐标系中的位置...

  • bounds & frame

    1、区别 frame: 该view在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统) bounds:...

网友评论

      本文标题:【技巧】View的Frame与Bounds区别

      本文链接:https://www.haomeiwen.com/subject/stcbqttx.html