Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

button sizetofit not working swift

class ResizableButton: UIButton {
    override var intrinsicContentSize: CGSize {
       let imageViewWidth = imageView?.frame.width ?? 0.0
       let labelSize = titleLabel?.sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude)) ?? .zero
       let desiredButtonSize = CGSize(width: labelSize.width + titleEdgeInsets.left + titleEdgeInsets.right + imageViewWidth, height: labelSize.height + titleEdgeInsets.top + titleEdgeInsets.bottom)

       return desiredButtonSize
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: swiftui pintch to zoom 
Swift :: underline uitextfield swift rotate 
Swift :: uicolor from hex swift 
Swift :: round up swift 
Swift :: swift access appdelegate from viewcontroller 
Swift :: how to add button dynamically in swift 4 
Swift :: xcode disable a button 
Swift :: how to download swift 
Swift :: hide bottom tab bar swift 
Swift :: get class name swift 
Swift :: post API Call in swift 
Swift :: button color swiftui 
Swift :: link swiftui 
Swift :: swift url request 
Swift :: change font of substring swift 
Swift :: create class swift 
Swift :: swift loop through 2 arrays at once 
Swift :: swift pop view controller 
Swift :: simple alert swifti 
Swift :: swift struct 
Swift :: swiftui radio button 
Swift :: === in swift 
Swift :: Swift guard-let Statement 
Swift :: swifter apply progress bar 
Swift :: swift 5 touchupinsideview 
Swift :: UINavigationBar turns black 
Swift :: get parent view controller in presentation mode swift 
Swift :: Swift Boolean Literals 
Swift :: Swift break and continue Inside Nested Loop 
Swift :: swift print statement 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =