CGRectInset的使用
来源:互联网 发布:windows 10 iso bt 编辑:程序博客网 时间:2024/04/28 21:44
在IntroduceToTextKitDemo中,在添加textView视图时使用了CGRectInset来定义其框架:
CGRect newTextViewRect = CGRectInset(self.view.bounds, 8., 0.);UITextView *newTextView = [[UITextView alloc] initWithFrame:newTextViewRect textContainer:container];
这是sdk包中的定义:
/* Inset `rect' by `(dx, dy)' -- i.e., offset its origin by `(dx, dy)', and decrease its size by `(2*dx, 2*dy)'. */CG_EXTERN CGRect CGRectInset(CGRect rect, CGFloat dx, CGFloat dy) CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
随后我写了一个Demo来试用一下,代码如下
- (void)viewDidLoad{ [super viewDidLoad]; CGRect rect = CGRectInset(self.view.bounds, 8., 0.); UIView *greenView = [[UIView alloc] initWithFrame:rect]; greenView.backgroundColor = [UIColor greenColor]; NSLog(@"greenView location:"); NSLog(@"x = %f", greenView.frame.origin.x); NSLog(@"y = %f", greenView.frame.origin.y); NSLog(@"width = %f", greenView.frame.size.width); NSLog(@"height = %f", greenView.frame.size.height); CGRect newRect0 = CGRectInset(greenView.frame, 0., 100.0); UIView *blueView = [[UIView alloc] initWithFrame:newRect0]; blueView.backgroundColor = [UIColor blueColor]; NSLog(@"blueView location:"); NSLog(@"x = %f", blueView.frame.origin.x); NSLog(@"y = %f", blueView.frame.origin.y); NSLog(@"width = %f", blueView.frame.size.width); NSLog(@"height = %f", blueView.frame.size.height); [greenView addSubview:blueView]; // 以greenView为参考坐标系添加blueView CGRect newRect = CGRectInset(greenView.bounds, 0., 200.0); UIView *blackView = [[UIView alloc] initWithFrame:newRect]; blackView.backgroundColor = [UIColor blackColor]; NSLog(@"blackView location:"); NSLog(@"x = %f", blackView.frame.origin.x); NSLog(@"y = %f", blackView.frame.origin.y); NSLog(@"width = %f", blackView.frame.size.width); NSLog(@"height = %f", blackView.frame.size.height); [greenView addSubview:blackView]; [self.view addSubview:greenView];}
0 0
- CGRectInset的使用
- CGRectInset的使用
- CGRectInset CGRectoffset UIEdgeInsetsInsetRect 这三个函数的使用情况
- CGRectInset CGRectoffset UIEdgeInsetsInsetRect 这三个函数的使用
- CGRectInset,CGRectOffset,UIEdgeInsetsInsetRect的使用说明
- ipnone CGRectInset 该结构体的应用
- CGRectOffset与CGRectInset的计算公式
- CGRectInset与CGRectOffset结构体的应用
- CGRectOffset与CGRectInset的计算公式
- CGRectOffset与CGRectInset的计算公式
- iOS CGRectInset与CGRectOffset的探究
- CGRectInset/CGRectOffset
- iOS CGRectInset
- CGRectInset和CGRectOffset区别
- IOS之CGRectInset->CGRectOffset
- CGRectInset、CGRectOffset详解
- CGRectInset、CGRectOffset…
- CGRectInset、CGRectOffset详解
- C内存对齐
- web集群之二 heartbeat实现ip漂移
- 关于 No operations allowed after connection closed.错误
- [Elasticsearch] 多字段搜索 (四) - 跨字段实体搜索
- 关于FD_CLOEXEC的一个故事 http://leave001.blog.163.com/blog/static/162691293201251810343121/
- CGRectInset的使用
- Vyatta2.0发布 博科押宝SDN
- 用JS scrollHeight方法实现textarea输入高度自适应的方法
- 各种数组排序方法
- 解决远程连接mysql错误1130
- [Elasticsearch] 多字段搜索 (五) - 以字段为中心的查询
- Look and Say-3438
- 写给大家看的项目管理书(第3版)——互动出版网
- jsp中的四大作用域