I am new to iOS application development and wanted to know how to use UIEdgeInsets
property in button so please guide me.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
First off, your question isn't very clear as to what you're attempting to achieve, so...ask a general question, get a general answer.
UIButton has three properties of type UIEdgeInsets –
contentEdgeInsets
,titleEdgeInsets
, andimageEdgeInsets
. You can use these properties to assign specific insets for all button content, including both the title and the image, or one or the other individually.You create UIEdgeInsets values using the
UIEdgeInsetsMake()
function. UIEdgeInsets encapsulates four different CGFloat values for the inset values of the top, left, bottom, and right (respectively) individually. Positive inset values shrink the content area, while negative inset values will effectively increase it.If you have a more specific question about how to use UIEdgeInsets with UIButton, I suggest you rethink how to ask it and try again. :)
Edit (to address question in comment): Sounds like you would want to do the following, then:
If you want an extension for Button and use simply, use this
Note that sometimes, you will not need to set the contentEdgeInsets. Just give the button a larger height and width constraints. The title itself will be center automatically.