Jon*_*rft 5 cocoa-touch objective-c uibutton uiimage ios
我有以下内容UIButton我想在最右边添加一个图像.像一个accessoryView
我已经在使用backgroundImage,我想避免将2个图像合并为1.
是否可以在UIButton中添加另一个图像,AccesoryView这个图像是一个PLUS最右边的图像?(我正在寻找一种在Button内插入新图像的方法)

@luisCien评论
我试过了
[_addImage setImage:[UIImage imageNamed:@"shareMe"] forState:UIControlStateNormal];
_addImage.contentHorizontalAlignment =
UIControlContentHorizontalAlignmentRight;
Run Code Online (Sandbox Code Playgroud)
它看起来像这样,我想将图像放在文本的右侧. 
Tom*_*voy 13
只需将其添加为子视图并选择您的坐标.尝试这样的事情:
UIImageView *yourPlusSign = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yourPlusSignImageTitle"]];
yourPlusSign.frame = CGRectMake(x, y, width, height);//choose values that fit properly inside the frame of your baseButton
//or grab the width and height of yourBaseButton and change accordingly
yourPlusSign.contentMode=UIViewContentModeScaleAspectFill;//or whichever mode works best for you
[yourBaseButton addSubview:yourPlusSign];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11140 次 |
| 最近记录: |