2.ios拖控件
来源:互联网 发布:网络运营商选择 编辑:程序博客网 时间:2024/05/22 06:57
1.IBAction:
1> 能保证方法可以连线
2> 相当于void
-(IBAction)
2.IBOutlet:
1> 能保证属性可以连线
@property (weak,nonatomic)IBOutlet
3.常见错误
setValue:forUndefinedKey:]: this class is not key value coding
错误原因是:连线出问题了
4.Xcode5开始的一些建议
把用于连线的一些方法和属性声明在.m文件的类扩展中
CGRect tempBounds = self.head.bounds; // 2.改变临时属性 tempBounds.size.width += 20; tempBounds.size.height += 20; // 3.用临时属性覆盖原来的属性 self.head.bounds = tempBounds;
5.frame\center\bounds
1> frame:能修改位置和尺寸
不能用点语法直接修改frame属性的值
CGRect btnFrame = self.controlName.frame; btnFrame.origin.y -= 10; self.controlName.frame = btnFrame;
2> center:能修改位置
不能用点语法直接修改center属性的值
CGPoint tempCenter = self.head.center;tempCenter.x += 10;self.head.center = tempCenter;
3> bounds:能修改尺寸(x\y一般都是0)
不能用点语法直接修改bounds属性的值
CGRect tempBounds = self.head.bounds; tempBounds.size.width += 20; self.head.bounds = tempBounds;
6.自动生成连线信息
按住control 拖控件
7.代码动态创建控件
- (void)viewDidLoad{ [super viewDidLoad]; NSLog(@"-----viewDidLoad"); // 添加 // 1.创建按钮 UIButton *btn = [[UIButton alloc] init]; // 2.添加按钮 [self.view addSubview:btn]; // 3.设置frame btn.frame = CGRectMake(100, 100, 100, 100); // 4.设置背景色 btn.backgroundColor = [UIColor blueColor]; // UIImage *image = [UIImage imageNamed:@"btn_01"];// [btn setBackgroundImage:image forState:uicontrolstate];}
// 0.开始动画 [UIView beginAnimations:nil context:nil]; // 动画持续2秒 [UIView setAnimationDuration:2.0]; // 1.取出原来的属性 CGRect tempBounds = self.head.bounds; // 2.改变临时属性 tempBounds.size.width += 50; tempBounds.size.height += 50; // 3.用临时属性覆盖原来的属性 self.head.bounds = tempBounds; // 4.提交动画 [UIView commitAnimations];
0 0
- 2.ios拖控件
- iOS 控件
- ios控件
- IOS控件
- ios 控件
- IOS控件学习
- ios控件学习2:
- iOS 控件系列:UIActionSheet
- iOS开发:UIPickerView控件
- 关于Tab控件 iOS
- UIControl IOS控件编程
- UIControl IOS控件编程
- IOS 控件 UIButton button
- IOS 控件 UITextField textField
- iOS-选择控件 UISegmentedControl
- iOS开发:UIPickerView控件
- IOS控件UILabel总结
- IOS控件UIToolBar、UIView
- Android中BroadcastReceiver如何使用Intent
- sphinx php api使用讲解
- 彩票审计风暴起 万亿巨资去那里?
- 安慰奶牛
- linux find command
- 2.ios拖控件
- 我的c语言笔记---字符串
- 设计模式 观察者模式
- 代码高亮之prettify
- 从写软件到买软件2
- uvaoj 10130-SuperSale 动态规划
- uva 11151(dp)
- centos 安装yum
- 安装linux发生的无法引导windows以及windows分区变为raw的解决