FlatButtonKit is written by Swift and make Flat Style Button from UILabel.
- Swift 4.2
- iOS 8.0 or later
- Cartfile
github "keygx/FlatButtonKit"
or
github "keygx/FlatButtonKit" "branch-name"
or
github "keygx/FlatButtonKit" "tag"
- install
$ carthage update
To integrate "FlatButtonKit.framework" into your Xcode project
- PodFile
platform :ios, '8.0'
target '<Your Target Name>' do
use_frameworks!
pod 'FlatButtonKit', :git => 'https://github.com/keygx/FlatButtonKit'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
or
platform :ios, '8.0'
target '<Your Target Name>' do
use_frameworks!
pod 'FlatButtonKit', :git => 'https://github.com/keygx/FlatButtonKit', :branch => 'branch-name'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
or
platform :ios, '8.0'
target '<Your Target Name>' do
use_frameworks!
pod 'FlatButtonKit', :git => 'https://github.com/keygx/FlatButtonKit', :tag => 'tag'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
- install
$ pod install
- Inherit FlatButtonKit class
- For more information: SampleButtonStyle.swift
import FlatButtonKit
~~
class SampleButtonStyle: FlatButtonKit {
~~
override func setButtonStyle(status: ButtonStatus) {
~~
switch status {
case .disabled:
// Disabled Style Stettings...
case .highlighted:
// Highlight Style Stettings...
case .selected:
// Selected Style Stettings...
default:
// Normal Style Stettings...
}
}
}
###Layout UILabel
###Setting Custom Class
###Code written
class ViewController: UIViewController {
@IBOutlet weak var button: SampleButtonStyle!
@IBOutlet weak var btn1: SampleButtonStyle!
@IBOutlet weak var btn2: SampleButtonStyle!
@IBOutlet weak var btn3: SampleButtonStyle!
override func viewDidLoad() {
super.viewDidLoad()
button.title.normal = "Normal"
button.title.highlighted = "Highlighted"
button.title.selected = "Selected"
button.title.disabled = "Disabled"
button.status = .normal
button.tag = 1
// set Touch Event
button.setTarget(target: self, selector: #selector(didTapped(_:))) // -> func didTapped(sender:)
or
// set Click Handler
button.setClickHandler() { sender in
print("ClickHandler: \(sender.tag)")
}
}
// Receive Touch Event
@objc func didTapped(_ sender: Timer) {
if let sender: AnyObject = sender.userInfo {
print("didTapped: \(($0 as AnyObject).tag)")
}
}
~~
}
###Run Application
AlertHelperKit is released under the MIT license. See LICENSE for details.
Yukihiko Kagiyama (keygx) https://twitter.com/keygx