How can I make a button's title at bottom and centered programmatically?
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- Using if let syntax in switch statement
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
- Swift - Snapshotting a view that has not been rend
Subclass
NSButtonCell
and overridedrawTitle:withFrame:inView:
(drawTitle(_,withFrame,inView)
in swift) to draw the title centered by manipulatingframe
parameter for example, or draw the title by yourself. Then set your button's cell class to your subclass.Or place
NSTextField
over your button, set constraints to anchor the bottomcenter of the button and set its text to whatever you want, and keep your buttons title empty.Unfortunately, there is no
contentHorizontalAlignment
property, like in iOS, so you have to solve it with subclass or a different UI composing.