`
810364804
  • 浏览: 785650 次
文章分类
社区版块
存档分类
最新评论

iOS开发 frame 与 bounds 的区别与关系

 
阅读更多

frame和bounds是UIView中的两个属性(property)。

frame指的是:该view在父view坐标系统中的位置和大小。(参照点是父亲的坐标系统)

bounds指的是:该view在本身坐标系统中 的位置和大小。(参照点是本身坐标系统)

-(CGRect)frame{
  return CGRectMake(self.frame.origin.x,self.frame.origin.y,self.frame.size.width,self.frame.size.height);
}
-(CGRect)bounds{
  return CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
}


本文链接http://unmi.cc/ios-bounds-frame, 来自隔叶黄莺 Unmi Blog

[版权声明]本站内文章,如未特别注明,均系原创或翻译之作,本人 Unmi 保留一切权利。本站原创及译作未经本人许可,不得用于商业用途及传统媒体。网络媒体可随意转载,或以此为基础进行演译,但务必以链接形式注明原始出处和作者信息,否则属于侵权行为。另对本站转载他处文章,俱有说明,如有侵权请联系本人,本人将会在第一时间删除侵权文章。及此说明,重之之重。

分享到:
评论

相关推荐

    iOS view的frame和bounds之区别.pdf

    iOS view的frame和bounds之区别.pdf

    ios开发记录

    //索引为0表示先添加的子视图,跟子视图的tag没有关系 //交换两个子视图的先后位置 [self.window exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; exchange交换 Subview 代替 //remove 移除 from 从 superview ...

    leetcode题库-iOS-Interview-Questions:收集整理iOS笔试面试题

    leetcode题库 iOS-Interview-Questions ...frame 和 bounds 写一个宏MIN,这个宏输入两个参数并返回较小的一个 #define MIN(a,b) ((a)>(b)?(b):(a)) 什么是KeyPath #import、#include、@class的区别? UIView和CALa

    iOS开发中一些手写控件及其相关属性的使用

    手写控件,frame,center和bounds属性 一、手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4)如果是button等控件,还需考虑控件的单击事件等 ...

    ios-多个 父子视图同时放大.zip

    主要是为了给那些frame和bounds傻傻分不清楚的小伙伴的

    ios-新特性引导页.zip

    window = UIWindow(frame: UIScreen.main.bounds) if !UserDefaults.standard.bool(forKey: "alreadyUsedApp"){ // 未使用过App,首次使用 let images:[UIImage] = [UIImage(named:"1")!,UIImage(named:...

    ios-DMRefreshControl.com

    使用Swift,封装了一个不一样的GearRefreshControl,继承自UIRefreshControl。...,初始化:refreshControl = GearRefreshControl(frame:self.view.bounds).使用方法refreshControl.addTarget()即可。

    ios-国际化和本地化(支持英语单复数问题).zip

    默认UITableView是UITableViewStyleGrouped组模式,Frame是self.view.bounds的大小,继承者可重写setBaseTableView方法修改TableView和添加tableHeaderView和tableFooterView等属性! 内部提供可以跳转Model和基本...

    iphone开发笔记

    退回输入键盘 2 CGRect 2 CGPoint & CGSize 3 设置透明度 3 设置背景色 3 自定义颜色 3 竖屏 3 横屏 3 ...iPhone里的frame和bounds区别 43 Objective-C内存管理 44 iphone更改键盘右下角按键的type 45

    iOS bounds学习笔记以及仿写UIScrollView部分功能详解

    经常看到这种说法,frame是基于父控件的,bounds是基于自身坐标的。然而,这个自身坐标是什么?bounds这个属性存在的意义是什么呢?bounds的x和y值真的永远是0吗? 经过查阅资料,我看到这样一种说法:一个控件,...

    ios-时间选择器.zip

    view.frame = CGRectMake(0, self.view.bounds.size.height-240, self.view.bounds.size.width, 240); //view.dateLimitNum = 0; view.hoursType = UIHoursTypeWork; view.minutesType = UIMinutesTypeAll; ...

    ios-一款简单好用的跑马灯效果-swift.zip

    1、初始化 drawMarqueeView = WQScrollLabelView(frame: CGRect(x: 0, y: 104, width: self.view.bounds.width, height: 20)) 2、设置属性 drawMarqueeView.marqueeDirection = .left view.addSubview...

    IOS入门之HelloWorld源代码

    frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, ...

    FrameBoundsRotate

    iOS设备横屏时,frame和bounds的分别该博客对应的Demo,只有真机测试才能看出问题。原文地址:http://blog.csdn.net/jymn_chen/article/details/37922757

    Programming.iOS.9

    The Window 4 Experimenting With Views 7 Subview and Superview 8 Visibility and Opacity 11 Frame 12 Bounds and Center 13 Window Coordinates and Screen Coordinates 17 Transform 18 Trait Collections and ...

    SearchBar和tableView 组合并且不遮住状态栏

    ios7 demo下载 searchbar与状态栏重叠已修复。 关键代码: -(void)viewDidLoad{ [super viewDidLoad]; // self.table.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];//去除多余行 //设置table...

    iOS-GridView:iOS自定义网格组件,基于UICollectionView的GridView

    MLHGridView *grid = [[MLHGridView alloc]initWithFrame:CGRectMake(10, 64, self.view.frame.size.width-20, CGRectGetHeight(self.view.bounds) - 64)]; grid.delegate = self; 2、实现delegate (NSInteger)...

    iOS CoreAnimation 图层几何学

    在UIView中与位置,尺寸有关的属性有 frame bounds center在此不多赘述,在CALayer中同样有与其相对应的属性 frame bounds position 需要注意的是 center与position 虽然字面表达不一样,但是其功能是一致的,为了更加...

    iOS-UI控件常见属性总结

    @property(nonatomic) CGRect frame; // 控件的位置和尺寸(以控件本身的左上角为坐标原点) @property(nonatomic) CGRect bounds; // 控件的中点位置(以父控件的左上角为坐标原点) @property(nonatomic) CGPoint ...

Global site tag (gtag.js) - Google Analytics