gpt4 book ai didi

ios - 用户界面按钮 : How to set image and text using imageEdgeInsets and titleEdgeInsets?

转载 作者:行者123 更新时间:2023-11-29 03:49:37 27 4
gpt4 key购买 nike

我有一个应用程序,其中使用 UIButton 以及 titleUIImage。他们的对齐似乎是第一个标题,然后是UIImage

我试过这个:

[dropdownbutton setImage: [UIImage imageNamed:@"down_sml_arrow.png"] 
forState:UIControlStateNormal];
CGFloat spacing = 10; // the amount of spacing to appear between image and title
dropdownbutton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, spacing);
dropdownbutton.titleEdgeInsets = UIEdgeInsetsMake(0, spacing, 0, 0);
[dropdownbutton setTitle:@"Your text" forState:UIControlStateNormal];

但是这里UIImage出现在标题之前。有人能指出我哪里出错了吗?

最佳答案

替代

UIImageView *imageView1=[[UIImageView alloc]init];
UIButton *dropdownbutton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
dropdownbutton.frame=CGRectMake(50, 50, 120, 50);
imageView1.image=[UIImage imageNamed:@"arrows.png"];
imageView1.frame=CGRectMake(85, 12, 25, 25);
dropdownbutton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[dropdownbutton addSubview:imageView1];
CGFloat spacing = 10; // the amount of spacing to appear between image and title
dropdownbutton.titleEdgeInsets = UIEdgeInsetsMake(0, spacing, 0, 0);
[dropdownbutton setTitle:@"Your text" forState:UIControlStateNormal];
[self.view addSubview:dropdownbutton];

关于ios - 用户界面按钮 : How to set image and text using imageEdgeInsets and titleEdgeInsets?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17212531/

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