Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

10 changes: 8 additions & 2 deletions DesignableButton/DesignableButton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2E23KCX8SU;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = DesignableButton/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.DesignableButton;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -317,12 +320,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2E23KCX8SU;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = DesignableButton/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.DesignableButton;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion DesignableButton/DesignableButton/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

DesignableButton.setDesignableStyles()
Expand Down
22 changes: 11 additions & 11 deletions DesignableButton/DesignableButton/DesignableButton+Styles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ extension DesignableButton {

DesignableButton.setStyle(style: { (designableButton: DesignableButton) -> Void in
if designableButton.isHighlighted || designableButton.isSelected {
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControl.State())
designableButton.backgroundColor = designableButton.selectedColor ?? Color.redSelected()
designableButton.layer.borderColor = designableButton.selectedColor?.cgColor ?? Color.redSelected().cgColor
designableButton.layer.borderWidth = designableButton.borderWidth ?? 0
} else if designableButton.isEnabled {
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControl.State())
designableButton.backgroundColor = designableButton.defaultColor ?? Color.red()
designableButton.layer.borderColor = designableButton.defaultColor?.cgColor ?? Color.red().cgColor
designableButton.layer.borderWidth = designableButton.borderWidth ?? 0
}
else {
designableButton.setTitleColor(designableButton.customTextColor ?? Color.gray(), for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? Color.gray(), for: UIControl.State())
designableButton.backgroundColor = designableButton.disabledColor ?? Color.grayLightest()
designableButton.layer.borderColor = designableButton.borderColor?.cgColor ?? Color.gray().cgColor
designableButton.layer.borderWidth = designableButton.borderWidth ?? 1
Expand All @@ -45,14 +45,14 @@ extension DesignableButton {

DesignableButton.setStyle(style: { (designableButton: DesignableButton) -> Void in
if designableButton.isHighlighted || designableButton.isSelected {
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControl.State())
designableButton.backgroundColor = designableButton.selectedColor ?? Color.redSelected()
} else if designableButton.isEnabled {
designableButton.setTitleColor(designableButton.customTextColor ?? Color.red(), for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? Color.red(), for: UIControl.State())
designableButton.backgroundColor = designableButton.defaultColor ?? UIColor.white
}
else {
designableButton.setTitleColor(designableButton.customTextColor ?? Color.grayLight(), for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? Color.grayLight(), for: UIControl.State())
designableButton.backgroundColor = designableButton.disabledColor ?? Color.grayLightest()
}
designableButton.setTitle(designableButton.titleLabel?.text, for: .normal)
Expand All @@ -64,27 +64,27 @@ extension DesignableButton {

DesignableButton.setStyle(style: { (designableButton: DesignableButton) -> Void in
if designableButton.isHighlighted {
designableButton.setTitleColor(designableButton.customTextColor ?? Color.redSelected(), for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? Color.redSelected(), for: UIControl.State())
designableButton.backgroundColor = designableButton.selectedColor ?? Color.red()
designableButton.tintColor = Color.redSelected()
}
else if designableButton.isSelected {
designableButton.setTitleColor(designableButton.customTextColor ?? Color.redSelected(), for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? Color.redSelected(), for: UIControl.State())
designableButton.backgroundColor = designableButton.selectedColor ?? UIColor.clear
designableButton.tintColor = Color.redSelected()
} else if designableButton.isEnabled {
designableButton.setTitleColor(designableButton.customTextColor ?? Color.red(), for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? Color.red(), for: UIControl.State())
designableButton.backgroundColor = designableButton.defaultColor ?? UIColor.clear
designableButton.tintColor = Color.red()
}
else {
designableButton.setTitleColor(designableButton.customTextColor ?? Color.grayLight(), for: UIControlState())
designableButton.setTitleColor(designableButton.customTextColor ?? Color.grayLight(), for: UIControl.State())
designableButton.backgroundColor = designableButton.disabledColor ?? UIColor.clear
designableButton.tintColor = Color.grayLight()
}

if isInterfaceBuilder {
designableButton.setImage(designableButton.image(for: .normal)?.withRenderingMode(UIImageRenderingMode.alwaysTemplate), for: .normal)
designableButton.setImage(designableButton.image(for: .normal)?.withRenderingMode(UIImage.RenderingMode.alwaysTemplate), for: .normal)
}

designableButton.alignImageAndTitleVertically()
Expand Down
2 changes: 2 additions & 0 deletions IHDesignableButton.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ Common button styles, such as corner radius, are also made available in Interfac

s.framework = "UIKit"
s.requires_arc = true

s.swift_version = '4.2'
end
6 changes: 3 additions & 3 deletions Sources/DesignableButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ open class DesignableButton: UIButton {

if self.adjustsFontSizeToFitWidth {
// When dynamic text changes we need to redraw the layout
NotificationCenter.default.addObserver(forName: .UIContentSizeCategoryDidChange, object: nil, queue: OperationQueue.main) { [weak self] notification in
NotificationCenter.default.addObserver(forName: UIContentSizeCategory.didChangeNotification, object: nil, queue: OperationQueue.main) { [weak self] notification in
guard let strongSelf = self else { return }
strongSelf.setNeedsLayout()
}
}
else {
NotificationCenter.default.removeObserver(self, name: .UIContentSizeCategoryDidChange, object: nil)
NotificationCenter.default.removeObserver(self, name: UIContentSizeCategory.didChangeNotification, object: nil)
}
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ open class DesignableButton: UIButton {

layer.masksToBounds = layer.cornerRadius > 0

assert(self.buttonType == UIButtonType.custom, "Designable Button \"\(self.titleLabel?.text ?? "?")\" buttonType must be Custom")
assert(self.buttonType == UIButton.ButtonType.custom, "Designable Button \"\(self.titleLabel?.text ?? "?")\" buttonType must be Custom")
}
}

Expand Down