gpt4 book ai didi

IOS开发UIButton(左边图片右边文字效果)

转载 作者:qq735679552 更新时间:2022-09-28 22:32:09 27 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章IOS开发UIButton(左边图片右边文字效果)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

在使用UIButton的时候,需要实现UIButton左边图片,图片后面紧跟文字效果比较麻烦,简单实现方法具体代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
( void )viewDidLoad {
   [super viewDidLoad];
   self.view.backgroundColor = RGB(235, 235, 240);
   UIButton *oneButton = [[UIButton alloc] initWithFrame:CGRectMake(0, kHeaderHeight + 8, kScreenWidth, 40)];
   [oneButton setImage:[UIImage imageNamed:@ "icon_party_knowledge_rights_obligations" ] forState:UIControlStateNormal];
   [oneButton setTitle:@ "第一个" forState:UIControlStateNormal];
   oneButton.titleLabel.font = FONT(12);
   [oneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
   [oneButton setImageEdgeInsets:UIEdgeInsetsMake(2, 8, 0, kScreenWidth - 50)];
   [oneButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, kScreenWidth - 100)];
   oneButton.backgroundColor = [UIColor whiteColor];
   [oneButton addTarget:self action:@selector(oneButtonAction:) forControlEvents:UIControlEventTouchUpInside];
   [self.view addSubview:oneButton];
   
   UIButton *twoButton = [[UIButton alloc] initWithFrame:CGRectMake(0, oneButton.maxY + 8, kScreenWidth, 40)];
   [twoButton setImage:[UIImage imageNamed:@ "icon_party_knowledge_dues_collection_standard" ] forState:UIControlStateNormal];
   [twoButton setTitle:@ "第二个" forState:UIControlStateNormal];
   twoButton.titleLabel.font = FONT(12);
   [twoButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
   [twoButton setImageEdgeInsets:UIEdgeInsetsMake(2, 8, 0, kScreenWidth - 50)];
   [twoButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, kScreenWidth - 100)];
   twoButton.backgroundColor = [UIColor whiteColor];
   [twoButton addTarget:self action:@selector(twoButtonAction:) forControlEvents:UIControlEventTouchUpInside];
   [self.view addSubview:twoButton];
   
   //右箭头
   for ( int i = 0; i < 2; i++) {
     UIImageView *rightImgView = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth - 20, kHeaderHeight + 20 + i * 48, 7, 12)];
     rightImgView.image = [UIImage imageNamed:@ "icon_right" ];
     [self.view addSubview:rightImgView];
   }
}

实现效果:

IOS开发UIButton(左边图片右边文字效果)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.

最后此篇关于IOS开发UIButton(左边图片右边文字效果)的文章就讲到这里了,如果你想了解更多关于IOS开发UIButton(左边图片右边文字效果)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com