
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
github.com/IdleHandsApps/DesignableButton
DesignableButton is a UIButton subclass that uses a centralised and reusable styling. In InterfaceBuilder, drag and drop a DesignableButton, choose your style and its applied instantly in InterfaceBuilder
Add this to your CocoaPods Podfile. Note the IH prefix
pod 'IHDesignableButton'
Create an DesignableButton+Styles.swift extension file in your project
import UIKit
import IHDesignableButton // if DesignableButton is in CocoaPod
extension DesignableButton {
override open func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
DesignableButton.setDesignableStyles(isInterfaceBuilder: true)
}
static func setDesignableStyles(isInterfaceBuilder: Bool = false) {
// example style
DesignableButton.setStyle(style: { (designableButton: DesignableButton) -> Void in
if designableButton.isHighlighted || designableButton.isSelected {
// replace this with your style for selected/highlighted states
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControlState())
designableButton.backgroundColor = designableButton.selectedColor ?? UIColor.red
designableButton.layer.borderColor = designableButton.selectedColor?.cgColor ?? UIColor.red.cgColor
designableButton.layer.borderWidth = designableButton.borderWidth ?? 0
} else if designableButton.isEnabled {
// replace this with your style for the normal state
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControlState())
designableButton.backgroundColor = designableButton.defaultColor ?? UIColor.blue
designableButton.layer.borderColor = designableButton.defaultColor?.cgColor ?? UIColor.blue.cgColor
designableButton.layer.borderWidth = designableButton.borderWidth ?? 0
}
else {
// replace this with your style for the disabled state
designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.lightGray, for: UIControlState())
designableButton.backgroundColor = designableButton.disabledColor ?? UIColor.lightGray()
designableButton.layer.borderColor = designableButton.borderColor?.cgColor ?? UIColor.gray.cgColor
designableButton.layer.borderWidth = designableButton.borderWidth ?? 1
}
// replace this with your style for all states
designableButton.layer.cornerRadius = designableButton.cornerRadius ?? 12
designableButton.setTitle(designableButton.titleLabel?.text, for: .normal)
}, for: "primary") // this is the name/key of your style
}
}
In the setDesignableStyles()
method you can call DesignableButton.setStyle()
to create a new style. Most projects will only need a few button styles
In you AppDelegate's application(_ , didFinishLaunchingWithOptions()
call DesignableButton.setDesignableStyles()
Now in Interface Builder, drag a UIButton onto a view
Change the class to DesignableButton
and the module to IHDesignableButton
Change the button type from System
to Custom
Set the Button Style to "primary" or any other button style you're created
A Codable extension to decode arrays and to catch & log all decoding failures https://github.com/IdleHandsApps/SafeDecoder
An elegant solution for keeping views visible when the keyboard is being shown https://github.com/IdleHandsApps/IHKeyboardAvoiding
A fully automatic status bar overlay for No Internet Connection messages https://github.com/IdleHandsApps/StatusBarOverlay
It'd be great to hear about any cool apps that are using DesignableButton
Distributed under the MIT License
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.