腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
首页
标签
uibutton
#
uibutton
关注
专栏文章
(11)
技术视频
(0)
互动问答
(1)
如何以编程方式创建基本的UIButton?
2
回答
uibutton
、
编程
、
布局
人生的旅途
辣鸡前端
- (void)viewDidLoad { [super viewDidLoad]; [self addMyButton]; // Call add button method on view load } - (void)addMyButton{ // Method for creating button, with background image and other properties UIButton *playButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; playButton.frame = CGRectMake(110.0, 360.0, 100.0, 30.0); [playButton setTitle:@"Play" forState:UIControlStateNormal]; playButton.backgroundColor = [UIColor clearColor]; [playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ]; UIImage *buttonImageNormal = [UIImage imageNamed:@"blueButton.png"]; UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0]; [playButton setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal]; UIImage *buttonImagePressed = [UIImage imageNamed:@"whiteButton.png"]; UIImage *strechableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0]; [playButton setBackgroundImage:strechableButtonImagePressed forState:UIControlStateHighlighted]; [playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:playButton]; }...
展开详请
赞
0
收藏
0
评论
0
分享
- (void)viewDidLoad { [super viewDidLoad]; [self addMyButton]; // Call add button method on view load } - (void)addMyButton{ // Method for creating button, with background image and other properties UIButton *playButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; playButton.frame = CGRectMake(110.0, 360.0, 100.0, 30.0); [playButton setTitle:@"Play" forState:UIControlStateNormal]; playButton.backgroundColor = [UIColor clearColor]; [playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ]; UIImage *buttonImageNormal = [UIImage imageNamed:@"blueButton.png"]; UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0]; [playButton setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal]; UIImage *buttonImagePressed = [UIImage imageNamed:@"whiteButton.png"]; UIImage *strechableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0]; [playButton setBackgroundImage:strechableButtonImagePressed forState:UIControlStateHighlighted]; [playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:playButton]; }
热门
专栏
APP自动化测试
102 文章
41 订阅
iOS知识点
28 文章
15 订阅
学海无涯
234 文章
41 订阅
iOS 开发
25 文章
23 订阅
linux commands
66 文章
14 订阅
热门
标签
更多标签
ICP备案
云服务器
对象存储
云点播
即时通信 IM
实时音视频
DNS 解析 DNSPod
内容分发网络 CDN
人脸识别
私有网络
python
java
javascript
人工智能
android
领券