gpt4 book ai didi

ios - 在左侧对齐 UIButton 的图像和 UILabel

转载 作者:行者123 更新时间:2023-11-29 11:34:38 24 4
gpt4 key购买 nike

我目前有:
enter image description here

使用这段代码:

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);

我想要实现的是:
enter image description here

图像和 UILabel 应该位于 UIButton 的左侧,而不是中间。

最佳答案

试试 contentHorizo​​ntalAlignment 属性。

objective-C

button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

swift

button.contentHorizontalAlignment = .left

关于ios - 在左侧对齐 UIButton 的图像和 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50480177/

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