创建UIView对象的两种方法
来源:互联网 发布:软件杯报名时间 编辑:程序博客网 时间:2024/05/21 08:02
1.使用xib文件
通过xib的⽅式来创建视图对象
NSBundle *bundle = [NSBundlemainBundle]; //获取当前程序的文件目录
NSArray *arr = [bundle loadNibNamed:@"myView"owner:self options:nil];
UIView *myView = [arr objectAtIndex:0];
2.手动绘制
CGRectviewRect = CGRectMake(0,0, 100, 100);
UIView *myView = [[UIViewalloc] initWithFrame:viewRect];
UIView *myView = [[UIViewalloc] initWithFrame:viewRect];
参考:
Unarchives the contents of a nib file located in the receiver's bundle.
- (NSArray *)loadNibNamed:(NSString *)
name
owner:(id)owner
options:(NSDictionary *)options
Parameters
name
The name of the nib file, which need not include the .nib
extension.
owner
The object to assign as the nib’s File's Owner object.
options
A dictionary containing the options to use when opening the nib file. For a list of available keys for this dictionary, see Nib File Loading Options.
0 0
- 创建UIView对象的两种方法
- Javascript 创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- C++创建对象的两种方法
- 两种创建对象的方法
- C++创建对象的两种方法
- JavaScript 对象创建的两种方法
- windows内核Api的学习
- Netty了解与小试
- MySQL提示:Starting MySQL...The server quit without updating PID&n
- UIScrollView新手教程
- 表单的radio box toggle其checked值
- 创建UIView对象的两种方法
- Web文件下载等待效果的实现
- qt android录音程序添加 Android 权限
- java中冒号(:)的用法
- Android Studio 快捷键
- Babelfish(map容器)
- Xamarin在VS2012没有智能提示的解决办法
- 重定向到另一个终端
- OC (IOS) 字符串 字符 NSData相互转换(NSStrng char NSData)