iOS之重写frame和bounds的实用价值
来源:互联网 发布:大学生兼职数据调查 编辑:程序博客网 时间:2024/06/05 01:21
介绍一下自定义控件时重写frame和bounds的实用性
- 自己可以自由修改控件的大小
- 防止别人在使用你的自定义控件时任意修改你的自定义控件的大小
比如我新创建一个UIView类的控件,在 .m文件里重写frame和bounds
.h文件
#import <UIKit/UIKit.h>@interface GDGTestView : UIView+ (instancetype)testView;@end
.m文件
#import "GDGTestView.h"@implementation GDGTestView+ (instancetype)testView{ return [[self alloc] init];}- (void)setFrame:(CGRect)frame{ frame.size = CGSizeMake(100, 100); [super setFrame:frame];}- (void)setBounds:(CGRect)bounds{ bounds.size = CGSizeMake(100, 100); [super setBounds:bounds];}
写上setFrame和setBounds方法后testView的大小永远是100x100,别人再写以下代码时不能改变你控件的大小
testView.frame = CGRectMake(0, 0, 10, 10); testView.bounds = CGRectMake(0, 0, 10, 10);
1 0
- iOS之重写frame和bounds的实用价值
- iOS之详解UIView的frame、bounds和center属性
- iOS-UIView属性之frame和bounds的区别
- iOS之UI基础---frame和bounds的区别
- ios view的frame和bounds之区别
- ios view的frame和bounds之区别
- iOS View的Frame和bounds之区别,setbounds使用
- iOS view 之 frame 和 bounds
- iOS学习之frame和bounds
- ios bounds 和 frame
- ios frame和bounds
- frame 和 bounds IOS
- ios-frame和bounds
- iOS 中frame 和 bounds 的区别
- ios视图frame和bounds的对比
- iOS中frame和bounds的区别
- iOS Frame和bounds的区别
- ios视图frame和bounds的对比
- HDU 3068 最长回文 最长回文子串
- Android开发遇到的
- 一道值得收藏的java面试题
- caffe BasePrefetchingDataLayer 学习
- UVA1329 合作网络 解题报告
- iOS之重写frame和bounds的实用价值
- maven概念
- Linux minerd木马清除
- 二叉搜索树与双向链表
- 1006. 换个格式输出整数 (15)
- WineQQ
- vm8.0下安装centos6.8
- 2015ACM-ICPC 北京赛区 Problem I. Snake Carpet
- TCP的拥塞控制详解