我希望您能够将UiButton中的标题和图像对齐,使标题显示在左侧,图像显示在极右侧。
请注意,按钮被拉伸以横向填充屏幕。
按钮布局应该如下所示: - [标题 .. ]
标题应该有一些左填充。 图像应该有一些右填充。
按钮布局应该如下所示: - [标题 .. ]
标题应该有一些左填充。 图像应该有一些右填充。
CGFloat width = self.frame.size.width;
CGFloat imageWidth = [button currentImage].size.width;
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[button setTitleEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
[button setImageEdgeInsets:UIEdgeInsetsMake(0, width - imageWidth - 10, 0, 0)];
然而,尽管标题是左对齐的,但它左侧有很多空白。图像根本不显示!
[UIView] > [UILabel + UIImageView] + UITapGestureRecognizer
这个怎么样? - TheTiger