Swift Extention

YYExtentions

鏈接地址:https://github.com/YaoChengZhen/YYExtentions.git
Installation

YYExtentions is available through CocoaPods. To install
it, simply add the following line to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'TargetName' do
pod 'YYExtentions', 
end

Then, run the following command:

pod install

Info

優點:不會影響現有的擴展,完全不侵入方式的擴展調用類似:view.snp.xxx
BlockButton: UIbutton Block功能
YDateExtention: 日期擴展
YStringExtention: 有關String擴展,功能有:Md5加密、有關密碼、郵箱、車牌號、手機號、URL鏈接等等的校驗
YViewControllerExtntion: 目前僅僅只有:導航欄左右按鈕封裝
YViewExtention: View擴展,frame的擴展

Usage

UIViewController

import YYExtentions
//如果你想要全局是隻導入一次的話,用如下導入:
//@_exported import YYExtentions

override func viewDidLoad() {
    super.viewDidLoad()
    yy_kit.addLeftBtn("Hello") { [weak self](btn) in
    print("Hello world")
    }
}

String


"123456".yy_kit.toMd5Lower  //MD5加密返回:String
"1788777".yy_kit.isMobile // 手機號校驗返回:Bool

View

let centerX: CGFloat = view.yy_kit.centerX //獲取
view.yy_kit.setHeight(100)
view.yy_kit.setCenterX(300)//設置中心點
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章