STKitSwift 1.3

STKitSwift 1.3

STShenzhaoliang 维护。



  • 作者
  • shentian

STKitSwift

STKitSwift Banner

Platform Version Carthage compatible Language License

STKitSwift 是一组用于 加速应用开发 的有用类、结构和扩展。

安装和用法

    platform :ios, '10.0'
    xcodeproj 'Project.xcodeproj'
    use_frameworks!
    pod 'STKitSwift'
    

效果图片

变更日志

1.1

名称 功能描述 状态
STAlertView 对 UIAlertController 的 alert 风格封装 新增
STGradientButton 支持渐变色的按钮 新增
STGradientView IB 支持渐变色、阴影的视图 新增
STHUD 弱提示框 新增
STMoveButton 可移动按钮 新增
STPhoneTextField 指定文本显示样式与文本正则的手机号输入框 新增
STProgressView 支持渐变色的进度框 新增
STSegmentedControl 根据内容偏移的分段选择器 新增

1.2

名称 功能描述 状态
STTimerButton 支持计时与倒计时的按钮 新增
STAreaPickerView 省市区选择器 新增
STDatePickerView 年月日选择器 新增

1.3

名称 功能描述 状态
STHUD 支持图片与文本提示 更新

STAlertView

安装

pod 'STKitSwift/STAlertView'

示例

let title = "Flutter 与 iOS 原生 WebView 对比"
STAlertView.show(title: title, message: nil, cancelTitle: "取消", otherTitle: "确定") { (item) in
    print(item)
}

STGradientButton

安装

pod 'STKitSwift/STGradientButton'

示例

    private lazy var gradientButton: STGradientButton = {
        let gradientButton = STGradientButton()
        gradientButton.startColor = UIColor.init(red: 255.0/255, green: 76.0/255, blue: 21.0/255, alpha: 1)
        gradientButton.endColor =  UIColor.init(red: 255.0/255, green: 156.0/255, blue: 121.0/255, alpha: 1)
        gradientButton.setTitle("使用layer", for: .normal)
        gradientButton.layer.cornerRadius = 22
        gradientButton.layer.masksToBounds = true
        view.addSubview(gradientButton)
        return gradientButton
    }()

STGradientView

安装和用法

pod 'STKitSwift/STGradientView'

STHUD

安装与使用

pod 'STKitSwift/STHUD'

示例

STHUD.show("Hello World")

STMoveButton

安装与使用

pod 'STKitSwift/STMoveButton'

示例

private lazy var moveButton: STMoveButton = {
    let moveButton = STMoveButton()
    moveButton.setImage(UIImage.init(named: "icon_wheel"), for: .normal)
    view.addSubview(moveButton)
    return moveButton
    }()

STPhoneTextField

安装与使用

pod 'STKitSwift/STPhoneTextField'

示例

let tf3 = STPhoneTextField()
tf3.config.defaultConfig = STPhoneFormat.init(defaultPhoneFormat: "(####) #######")
tf3.prefix = "+86 "
tf3.placeholder = "format:+86 (####) #######"

STProgressView

安装和用法

pod 'STKitSwift/STProgressView'

STSegmentedControl

安装和用法

pod 'STKitSwift/STSegmentedControl'

示例

let titles = ["关注", "推荐", "国际", "娱乐", "视频", "科技", "军事", "设计", "体育", "读书"]
let segmentedControl = STSegmentedControl()
segmentedControl.titles = titles
segmentedControl.selectBlock = { (item) in
            print(item)
        }
segmentedControl.currentIndex = 3

STTimerButton

安装和用法

pod 'STKitSwift/STTimerButton'

示例

buttonCode.startCountDown(duration: 10) { (button, type, time)  in
print("button = \(button) type = \(type) time = \(time)")
    switch type {
    case .start:
        button.isEnabled = false
        button.setTitle(time.description + "s", for: .normal)
        button.backgroundColor = .gray
    case .ongoing:
        button.isEnabled = false
        button.setTitle(time.description + "s", for: .normal)
        button.backgroundColor = .gray
    case .finish:
        button.isEnabled = true
        button.setTitle("重新发送", for: .normal)
        button.backgroundColor = .red
    default:
        button.isEnabled = true
    }
}

STAreaPickerView

安装与使用

pod 'STKitSwift/STAreaPickerView'

示例

STAreaPickerView.show(inView: view) { [weak self](provinceName, provinceCode, cityName, cityCode, areaName, areaCode) in

}

STDatePickerView

安装与使用

pod 'STKitSwift/STDatePickerView'

示例

STDatePickerView.show(minimumDateStr: "1900-01-01",
                              maximumDateStr: "3000-01-01",
                              currentDateStr: "2019-06-04")
        { (year, month, day)in
            print("year = \(year)  month = \(month)  day = \(day)")
        }