给UIButton添加背景图片
生活随笔
收集整理的這篇文章主要介紹了
给UIButton添加背景图片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//定義一個button ??
UIButton * button = [UIButton buttonWithType:(UIButtonTypeRoundedRect)];
//大小
? ? button.frame =CGRectMake(10, 10, 50, 50);
//設置成圓形(根據需要) ??
button.layer.cornerRadius = button.frame.size.width /2;
? ? button.clipsToBounds = YES;
//調用添加圖片的方法
? ? [button setBackgroundImage:[UIImage imageNamed:@"add.png"] forState:(UIControlStateNormal)];
?
? ? [self.view addSubview:button];
?
轉載于:https://www.cnblogs.com/huhutongxue/p/5278507.html
總結
以上是生活随笔為你收集整理的给UIButton添加背景图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ajax 请求超过了5s 还没有返回
- 下一篇: bmp文件格式详细解析