ThinX 1.1.8

ThinX 1.1.8

JuanFelix 维护。



ThinX 1.1.8

  • iFallen

ThinX

CI Status Version License Platform

示例

要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install

主要
main

用法

配置 Plist

配置
config

导航栏外观

  • 从 config.plist 中的默认样式
NavBarAppearance.active()
  • 使用代码进行自定义
var navBuilder = NavBarBuilder.default
navBuilder.backgroundColor = UIColor.th.rgb(39, 168, 242)
navBuilder.buttonTextColor = UIColor.th.rgb(252, 30, 112)
navBuilder.titleColor = .red
navBuilder.titleFont = UIFont(name: "Copperplate", size: 18)!
navBuilder.isTranslucent = false
navBuilder.showSeparator = false
NavBarAppearance.active(navBuilder)

  • 在 viewcontroller 中设置颜色
self.th.setNavBarBackgroundColor(color)
self.th.setNavSubViewColor(color)
self.th.reloadNavSubViewColor()//reload to config plist define

TabBar外观

  • 默认样式来自config.plist配置文件
TabBarAppearance.active()
  • 使用代码进行自定义
var tabBuilder = TabBarBuilder.default
tabBuilder.backgroundColor = UIColor.th.rgb(39, 40, 34)
tabBuilder.selectedColor = UIColor.th.rgb(230, 220, 109)
tabBuilder.normalColor = .cyan
tabBuilder.font = UIFont(name: "Bradley Hand", size: 12)
tabBuilder.isTranslucent = false
tabBuilder.showSeparator = false
TabBarAppearance.active(tabBuilder)

  • 在viewController中设置backgroundColor
self.th.setTabBarBackgroundColor(color)

颜色用法(在config.plist文件中定义)

UIColor.th.tint
UIColor.th.subTint
UIColor.th.background
UIColor.th.title
UIColor.th.body
UIColor.th.subBody
UIColor.th.mark1
UIColor.th.mark2
UIColor.th.border
UIColor.th.empty
UIColor.th.random
UIColor.th.rgb(100, 200, 40)
UIColor.th.hexStr("#CCCCCC")

字体用法(在config.plist文件中定义)

UIFont.th.title()
UIFont.th.body()
UIFont.th.mark()
UIFont.th.title(size: 30)
UIFont.th.title(fix: -2)
UIFont.th.body(size: 12)
UIFont.th.body(fix: 1)
UIFont.th.font(.title, size: 20)
UIFont.th.pfFont(.medium, size: 20)
UIFont.th.bodyFontSize
UIFont.th.bodyFontName

UIViewController扩展

  • 添加NavBarButton
self.th.addNavBarButton(iconFontTexts: ["\u{e673}", "\u{e673}"], at: .left, iconFont: UIFont.init(name: "iconfont", size: 22)!, color: UIColor.cyan)
self.th.addNavBarButton(texts: ["Next"], at: .right)
self.th.addNavBarButton(images: ["image1", "image2"], at: .right, useOriginalColor: false)
self.th.clearNavBarBackButtonTitle()
self.th.addNavBarButtonItems(customView: view, at: .left)
override func rightBarButtonAction(index: Int) {
    let vc = UIViewController()
    vc.view.backgroundColor = UIColor.th.background
    navigationController?.pushViewController(vc, animated: true)
}
    
override func leftBarButtonAction(index: Int) {
    print("🐌 iconfont index: \(index)")
}

  • 键盘通知(KerboardNotification)
self.th.addKeyboardNotification()
self.th.removeKeyboardNotification()
override func keyboardWillShow(duration dt: Double, userInfo: Dictionary<String, Any>) {
    UIView.animate(withDuration: dt) {
        
    }
}
    
override func keyboardWillChangeFrame(beginRect: CGRect, endRect: CGRect, duration dt: Double, userInfo: Dictionary<String, Any>) {
    UIView.animate(withDuration: dt) {
        v.bottom = endRect.height
    }
}
    
override func keyboardWillHide(duration dt: Double, userInfo: Dictionary<String, Any>) {
    UIView.animate(withDuration: dt) {
        
    }
}

UIAlertViewController

UIAlertController.th.showAlert(...)
UIAlertController.th.showActionSheet(...)

ReuseIdentifier

UITableViewCell.th.reuseIdentifier
THTableViewCell.th.nibName

NSAttributedString

let attr =  NSAttributedString.th.string(...)
attr.th.setColor(...)
attr.th.setFont(...)

UIView 扩展

view.th.corners(.left)
view.th.corners(.right)
view.th.corners(.forwardSlash)
...

String

str.th.noticename //NSNotification.Name
str.th.currencyString(...)
str.th.attributedCurrencyStr(...)
...

UIDevice

UIDevice.th.width
UIDevice.th.height
UIDevice.th.isXSeries
UIDevice.th.topBarHeight
UIDevice.th.bottomBarHeight
...

…其他

... 

扩展 Thin 添加 [th] 支持

extension Thin where Base: [ClassType] {
	static func  
	func 
}

extension Thin where Base == [StructType] {
	static func  
	func 
}

要求

安装

Thin 可以通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ThinX'

作者

iFallen, [邮箱 protected]

许可

本站RGBA库遵循MIT许可。更多信息请参阅LICENSE文件。