UIButton标题和图像对齐查询 [英] UIButton title and image alignment query
问题描述
我有一个 UIButton
,我正尝试在其上设置标题和图片。
I have a UIButton
and I am trying to set a title and an image on it.
要将 UIButton
的标题对齐到左侧,并将图像对齐到右侧。我想在Timer中的应用程序(一个说当计时器结束的时候)的按钮的外观和感觉。
I would like to align the title for a UIButton
to the left side and place an image aligned to the right. I am trying to get the look and feel of the button in Timer in Clocks app (the one which says "When Timer Ends").
我充满了 contentHorizontalAlignment
, contentEdgeInsets
, titleEdgeInsets
和 imageEdgeInsets
实现我的目标,但无济于事。
I fiddled with contentHorizontalAlignment
, contentEdgeInsets
, titleEdgeInsets
and imageEdgeInsets
to achieve my goal, but to no avail. The documentation is also quite sparse for the same.
如何实现相同的功能?
,定时器在时钟应用程序有两组文本,一个对齐到左边和其他与图像对齐右?如何在 UIButton
中完成? (我现在不需要那个功能。)
Also related questions, Timer in Clocks app has two set of Text, one aligned to the left and other aligned right with the image? How can that be done in a UIButton
? ( I do not need that functionality though at the moment).
推荐答案
更改 imageEdgeInsets $在
UIButton
上使用 setImage:forState:
Change the imageEdgeInsets
property on the UIButton
and then just use setImage:forState:
这篇关于UIButton标题和图像对齐查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!