常用控件的初始化
来源:互联网 发布:小白素材vip源码 编辑:程序博客网 时间:2024/04/30 12:10
//UIView视图
UIView *gView = [UIViewnew];
UIView *view = [[UIViewalloc]initWithFrame:CGRectMake(10,10, 10,10)];
//UILabel标签
UILabel *label0 = [UILabelnew];
UILabel *label = [[UILabelalloc]initWithFrame:CGRectMake(10,40, 50,30)];
//UIWindow窗口_AppDelegate.m
UIWindow *window = [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];
window.rootViewController = [ViewControllernew];
[window makeKeyAndVisible];
//UIImageView图片视图
UIImageView *imageView = [[UIImageViewalloc]initWithFrame:CGRectMake(20,20, 80,80)];
//(20,20)->视图中心
imageView.center =self.view.center;
//位置大小改变
imageView.frame =CGRectMake(100,100, 100,200);
[self.viewaddSubview:imageView];
UIImage *im = [UIImageimageNamed:@"图片名"];
imageView.image = im;
//动画
imageView.image = [UIImageanimatedImageNamed:@"loading_"duration:0.5];
//内容模式:保持比例适应大小
imageView.contentMode =UIViewContentModeScaleAspectFit;
//UIControl:控制器
UIControl *blueC = [[UIControlalloc]initWithFrame:CGRectMake(20,20, 100,100)];
//按钮UIButton
UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeCustom];
[self.viewaddSubview:btn];
//位置在屏幕中心大小200,70
btn.frame =CGRectMake(0,0, 200,70);
btn.center =self.view.center;
//frame相对父视图的尺寸
CGFloat screenW = [UIScreenmainScreen].bounds.size.width;
CGFloat screenH = [UIScreenmainScreen].bounds.size.height;
UIView *blackView = [[UIViewalloc]initWithFrame:CGRectMake(screenW -100 - 20, screenH -100 - 20,100, 100)];
//masory轮子
UIView *leftBV = [UIViewnew];
[self.viewaddSubview:leftBV];
leftBV.backgroundColor = [UIColorlightGrayColor];
[leftBV mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(-20);
make.left.equalTo(20);
make.height.width.equalTo(100);
}];
//UISegmentedControl分段控制器_事件UIControlEventValueChanged
UISegmentedControl *segment = [[UISegmentedControlalloc]initWithItems:@[@"张三",@"李四",@"王五",@"赵六"]];
[self.viewaddSubview:segment];
segment.frame =CGRectMake(20,160, 300,40);
segment.selectedSegmentIndex =2;
//UISwitch开关_事件UIControlEventValueChanged
//自定义位置
UISwitch *sw0 = [[UISwitchalloc]initWithFrame:CGRectMake(50,200, 80,30)];
UISwitch *sw = [UISwitchnew];
sw.center =self.view.center;//屏幕中心
[self.viewaddSubview:sw];
//默认是开
sw.on =YES;
//边框颜色
sw.tintColor = [UIColororangeColor];
//开的底色
sw.onTintColor = [UIColororangeColor];
//圆球颜色
sw.thumbTintColor = [UIColorredColor];
//UIActivityIndicatorView活动指示器—菊花_UISwith控制isAnimating
UIActivityIndicatorView *aiv = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
//可设置位置,大小由Style控制
aiv.center =self.view.center;//中心
CGRect rect = aiv.frame;
rect.origin.x =200;
rect.origin.y =80;
aiv.frame = rect;
//UISlider滑动条_事件UIControlEventValueChanged
//高度默认31,自定义设置无效
UISlider *slider0 = [UISlidernew];
CGRect rect0 = slider0.frame;
rect0.size.width =self.view.frame.size.width - 100;
slider0.frame = rect0;
slider0.center =self.view.center;
UISlider *slider1 = [[UISlideralloc]initWithFrame:CGRectMake(10,50, 100,/*非0都为31*/5)];
//UIProgressView进度条高度无效_由UISlider控制
UIProgressView *progressView = [[UIProgressViewalloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
CGRect rect1 = progressView.frame;
rect1.size.width = [UIScreenmainScreen].bounds.size.width -100;
progressView.frame = rect1;
progressView.center =self.view.center;
//UIStepper步进器_UIControlEventValueChanged
UIStepper *stepper = [[UIStepperalloc]initWithFrame:CGRectMake(80,150, 80,30)];
//UIPageControl页面控制器
//只有位置无大小
UIPageControl *pc = [UIPageControlnew];
pc.center =self.view.center;
//UITextField文本输入框
UITextField *tf = [[UITextFieldalloc]initWithFrame:CGRectMake(0,0, [UIScreenmainScreen].bounds.size.width -100, 40)];
tf.center =self.view.center;
//UIScrollView 滚动视图
UIScrollView *scrollView = [[UIScrollViewalloc]initWithFrame:CGRectMake(20,20, 200,200)];
scrollView.backgroundColor = [UIColorgreenColor];
[self.viewaddSubview:scrollView];
imageView.image = [UIImageimageNamed:@"aad_fjk"];
[scrollView addSubview:imageView];
//内容大小
scrollView.contentSize =CGSizeMake(500,500);
//UITableView表格视图
UITableView *tableView =[[UITableViewalloc]initWithFrame:CGRectZerostyle:UITableViewStylePlain];//无分组
[self.viewaddSubview:tableView];
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(0);
}];
- 常用控件的初始化
- ios常用控件的初始化
- ios-控件的初始化
- 自定义控件的初始化方法
- MFC通用控件的初始化
- MFC通用控件的初始化
- vc列表控件的初始化
- string的常用初始化方式
- ASPxGridView控件常用示例二:添加和初始化新行
- 初始化控件
- Extjs常用的控件
- android 的常用控件
- 常用的web控件
- 控件的常用属性
- 常用的Web控件
- 常用的Web控件
- 【MFC】常用的控件
- 图片常用的控件
- 【排序】快速排序
- VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
- 安装完最小化 RHEL/CentOS 7 后需要做的 30 件事情(一)
- ClassNotFoundException: org.apache.ws.commons.schema.resolver.URIResolver
- 删除jar包的某些class重新打jar包
- 常用控件的初始化
- ContentProvider基础
- C/C++ 关于大小端模式
- UVA1594
- 前端学习总结(十七)React Native——移动开发的未来趋势
- 一段snmp代码
- SQLite 总结
- Poj 1741 Tree
- 倒排句子的单词