diff --git a/Example Apps/SparrowKit.xcodeproj/project.xcworkspace/xcuserdata/ivanvorobei.xcuserdatad/UserInterfaceState.xcuserstate b/Example Apps/SparrowKit.xcodeproj/project.xcworkspace/xcuserdata/ivanvorobei.xcuserdatad/UserInterfaceState.xcuserstate index d39ed3e..cfb57df 100644 Binary files a/Example Apps/SparrowKit.xcodeproj/project.xcworkspace/xcuserdata/ivanvorobei.xcuserdatad/UserInterfaceState.xcuserstate and b/Example Apps/SparrowKit.xcodeproj/project.xcworkspace/xcuserdata/ivanvorobei.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Sources/SparrowKit/UIKit/Classes/Buttons/SPLargeActionButton.swift b/Sources/SparrowKit/UIKit/Classes/Buttons/SPLargeActionButton.swift index 1cc3e5e..de1028f 100644 --- a/Sources/SparrowKit/UIKit/Classes/Buttons/SPLargeActionButton.swift +++ b/Sources/SparrowKit/UIKit/Classes/Buttons/SPLargeActionButton.swift @@ -45,6 +45,7 @@ open class SPLargeActionButton: SPDimmedButton { titleLabel?.font = UIFont.preferredFont(forTextStyle: .headline, addPoints: 1) titleLabel?.numberOfLines = 1 titleImageInset = 6 + contentEdgeInsets = .init(horizontal: 10, vertical: .zero) } // MARK: - Public @@ -72,7 +73,18 @@ open class SPLargeActionButton: SPDimmedButton { } open override func sizeThatFits(_ size: CGSize) -> CGSize { - return CGSize(width: size.width, height: 50) + let superSize = super.sizeThatFits(size) + let width = superSize.width + + var height = superSize.height + 28 + if let titleLabel = titleLabel, let imageView = imageView, let _ = imageView.image { + if titleLabel.frame.height > 0 && imageView.frame.height > 0 { + let imageCorrection = imageView.frame.height - titleLabel.frame.height + height -= imageCorrection + } + } + + return CGSize(width: width, height: height) } // MARK: - Ovveride diff --git a/Sources/SparrowKit/UIKit/Classes/Buttons/SPSmallActionButton.swift b/Sources/SparrowKit/UIKit/Classes/Buttons/SPSmallActionButton.swift index 69118e4..fcf931f 100644 --- a/Sources/SparrowKit/UIKit/Classes/Buttons/SPSmallActionButton.swift +++ b/Sources/SparrowKit/UIKit/Classes/Buttons/SPSmallActionButton.swift @@ -54,10 +54,10 @@ open class SPSmallActionButton: SPDimmedButton { SparrowKit: Wrapper of set content and color of button. - parameter title: Text which using like title. - - parameter icon: Object of `UIImage`, using like icon. + - parameter icon: Object of `UIImage`, using like icon. Usually Apple doesn't use icon in this button. - parameter colorise: Color of button in default state. */ - public func set(title: String, icon: UIImage?, colorise: SPDimmedButton.Colorise) { + public func set(title: String, icon: UIImage? = nil, colorise: SPDimmedButton.Colorise) { setTitle(title) if let icon = icon { setImage(icon.alwaysTemplate) @@ -84,6 +84,7 @@ open class SPSmallActionButton: SPDimmedButton { height -= imageCorrection } } + return CGSize(width: width, height: height) }