使用这段代码:
button.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
button.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.titleLabel.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
图像和 UILabel 应该位于 UIButton 的左侧,而不是中间。
最佳答案
试试 contentHorizontalAlignment
属性。
objective-C
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
swift
button.contentHorizontalAlignment = .left
关于ios - 在左侧对齐 UIButton 的图像和 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50480177/