iOS之代码创建button
2015-10-21 21:37
344 查看
在storyBoard连线的时候,方法返回值是IBAction,所谓IBAction就是可以连线的void
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(110.0,
220.0, 100.0,
40.0)];
[button setTitle:@"button默认状态"
forState:UIControlStateNormal];
[button setTitle:@"button点击状态"
forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor
redColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor
greenColor] forState:UIControlStateHighlighted];
[button setBackgroundColor:[UIColor
orangeColor]];
//点击执行的函数
[button addTarget:self
action:@selector(tapButton)
forControlEvents:UIControlEventTouchUpInside];
[self.view
addSubview:button];
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(110.0,
220.0, 100.0,
40.0)];
[button setTitle:@"button默认状态"
forState:UIControlStateNormal];
[button setTitle:@"button点击状态"
forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor
redColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor
greenColor] forState:UIControlStateHighlighted];
[button setBackgroundColor:[UIColor
orangeColor]];
//点击执行的函数
[button addTarget:self
action:@selector(tapButton)
forControlEvents:UIControlEventTouchUpInside];
[self.view
addSubview:button];
相关文章推荐
- iOS中 CGGeometry 类方法总结
- 零基础ios开发(一 改变图片大小和位置)
- 开始记录 iOS后台计时的代码。
- 【IOS 开发学习总结-OC-62】IOS 应用的生命周期
- iphone ios 屏幕,导航条,状态栏的高度
- 蓝懿iOS 技术内容和心得 10。21
- IOS开发笔记4-流程控制/基本语句
- IOS 关于内置高德地图的使用(三)
- IOS 关于内置高德地图的使用(二)
- IOS 关于内置高德地图的使用设置(一)
- iOS 获取自定义cell上按钮所对应cell的indexPath.row的方法
- iOS经典讲解之NSUserDefaults
- standardUserDefaults
- 【IOS 开发学习总结-OC-61】IOS 的自动旋转
- IOS开发笔记3-SCANF函数使用和表达式
- IOS构建XMPP开发
- iOS 原生扫码
- IOS学习 postNotificationName 消息传递详解
- iOS开发>学无止境 - 各种传值方式
- IOS学习 NSAssert和NSAssertion?Handler:断言相关