简体   繁体   English

UIButton imageEdgeInsets在运行时不更新

[英]UIButton imageEdgeInsets not updating at run time

So here is my code, it's fairly strait forward. 所以这是我的代码,相当向前。

CGFloat spaceing = 5;

self.premiumButton.imageEdgeInsets = UIEdgeInsetsMake(spaceing,spaceing,spaceing,spaceing)
 NSLog(@"immage - %@",    NSStringFromUIEdgeInsets(self.premiumButton.imageEdgeInsets));

right should update the Image to be in the center of the button with a 5 point padding on all sides(I've removed the text for this particular state) 右侧应将Image更新为按钮的中心,并在所有侧面各加5点填充(我已删除了此特定状态的文本)

but the log comes back with 但是日志返回

immage - {0, 0, 0, 0} 图片-{0,0,0,0}

Infact I placed this in initWithCoder which is how this view is being built from a xib and got the same thing despite the fact that in the interface builder I set everything. 实际上,我将其放在initWithCoder中,这是从xib构建此视图的方式,尽管在接口构建器中我已设置了所有内容,但得到的结果却是相同的。

What am I missing everything else on stack overflow has code samples that look just like mine marked as the answer but it's not doing anything for me. 我在堆栈溢出中缺少的所有其他内容都有看起来像我的代码示例一样被标记为答案,但它对我没有任何帮助。

I have tried the UIButton setTitleEdgeInsets method but no go. 我已经尝试过UIButton setTitleEdgeInsets方法,但是没有成功。

- (void)layoutSubviews update imageEdgeInsets

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自定义 UIButton imageEdgeInsets/titleEdgeInsets 不工作 - Custom UIButton imageEdgeInsets/titleEdgeInsets not working 如何使用 imageEdgeInsets 更改 UIButton 中图像的 tintColor? - How to change tintColor of image in UIButton with imageEdgeInsets? 使用Autolayout设置UIButton titleEdgeInsets和imageEdgeInsets很慢 - Setting UIButton titleEdgeInsets and imageEdgeInsets is slow with Autolayout 使用 imageEdgeInsets 和 titleEdgeInsets 对齐 UIButton 上的文本和图像 - Aligning text and image on UIButton with imageEdgeInsets and titleEdgeInsets UIButton标题不会一直更新 - UIButton Title not updating all the time UIButton:如何使用 imageEdgeInsets 和 titleEdgeInsets 将图像和文本居中? - UIButton: how to center an image and a text using imageEdgeInsets and titleEdgeInsets? 将 UIButton 标题右侧的图像与 imageEdgeInsets 和 titleEdgeInsets 对齐 - Aligning image on right side of title on UIButton with imageEdgeInsets and titleEdgeInsets 调整titleEdgeInsets和imageEdgeInsets时,UIButton上的标题和文本之间的空格不正确 - The space between title and text on UIButton is not correct when adjusting titleEdgeInsets and imageEdgeInsets UIButton:如何使用imageEdgeInsets和titleEdgeInsets设置图像和文本? - UIButton: How to set image and text using imageEdgeInsets and titleEdgeInsets? UIButton在运行时更改尺寸 - UIButton change dimensions at run time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM