小编use*_*123的帖子

我想制作一个带有三角形图标的按钮

我想制作一个带有三角形图标的按钮,就像iBooks app风格一样. 我想制作这个按钮(在iBooks应用程序中)

按下按钮时,将显示列表屏幕.然后选择一个列表,按钮的语句将是所选文本和三角形的图标.图标始终是右侧.

[self.button setImage:[UIImage imageNamed:@"arrow-down"] forState:UIControlStateNormal];
CGFloat titleWidth = self.button.titleLabel.bounds.size.width;
CGFloat imageWidth = self.button.imageView.bounds.size.width;
// Title is left Image is right
self.button.titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth, 0, imageWidth);
self.button.imageEdgeInsets = UIEdgeInsetsMake(0, titleWidth, 0, -titleWidth);
Run Code Online (Sandbox Code Playgroud)

所以我试着制作一个示例应用程序.

https://github.com/kawai-hiroyuki/LikeIBooksDropDownMenu

但是,图标的位置绝对会偏离.如何安装在右侧始终是图标.

iphone objective-c uibutton ios

1
推荐指数
1
解决办法
1242
查看次数

标签 统计

ios ×1

iphone ×1

objective-c ×1

uibutton ×1