CSSwiftExtension - 贡献一个非常好用的Swift extension集合
发布时间:2020-12-14 06:27:54 所属栏目:百科 来源:网络整理
导读:CSSwiftExtension是我个人开源的一个非常有用的Swift extension集合。支持CocoadPods和Carthage。 目前主要包含Foundation和UIKit的两类extension,基本使用如下: Foundation String extension let string = " hello 17,this is my city " let a = string .
CSSwiftExtension是我个人开源的一个非常有用的Swift extension集合。支持CocoadPods和Carthage。 FoundationString extensionlet string = " hello 17,this is my city "
let a = string.cs_trimmed
let b = string.cs_length
aNonUTF8String.cs_utf8String
let regExp_email = "^[a-zA-Z0-9]{1,}@[a-zA-Z0-9]{1,}.[a-zA-Z]{2,}$"
cs_validateWithRegExp(regExp: regExp_email)
Array extension[1,5,10].cs_sum
["a","b","c","a","c"].cs_removeDuplicates()
UIKitUIApplication extensionUIApplication.shared.cs_appVersion
UIApplication.shared.cs_currentViewController
UIColor extensionimageView.backgroundColor = UIColor(hexString: 0x123456,alpha: 0.5)
imageView.backgroundColor = UIColor.cs_random
UIImage extensionguard let image = UIImage(named: "Model.jpg") else { return }
let a = image.cs_imageMirrored
let b = image.cs_imageCropped(bounds: CGRect(x: 0,y: 0,width: 200,height: 200))
let c = image.cs_imageWithNormalOrientation
let d = image.cs_imageRotatedByDegrees(degrees: 90)
let e = image.cs_imageWithCornerRadius(cornerRadius: 100)
let f = image.cs_imageScaledToSize(targetSize: CGSize(width: 300,height: 300),withOriginalRatio: true)
let g = image.cs_wechatShareThumbnail
let h = image.cs_grayScale
// Thanks to https://github.com/bahlo/SwiftGif for gif support
aImageView.loadGif(name: "Railway")
aImageView.image = UIImage.gif(name: "Railway")
UIView extensionimageView.cs_snapShot()
let aView = AView.cs_loadFromNib("AView") as? AView
aView.cs_cornerRadius(corners: [.bottomLeft,.bottomRight],radius: 20)
UIImageView extensionlet imageView = UIImageView(frame: CGRect(x: 0,width: 300,height: 500),blurEffectStyle: .light)
UITableView extensionaTableView.cs_removeEmptyFooter()
aTableView.cs_scrollToTop(animated: true)
tableView.cs_register(MyTableViewCell.self)
let cell = tableView.cs_dequeueReusableCell(forIndexPath: indexPath) as MyTableViewCell
UIButton extensionbtnTest.cs_acceptEventInterval = 2 // to avoid UIButton's multiple click operation
btnTest.cs_setBackgroundColor(UIColor.blue,for: .normal) // set backgroundColor
btnTest.cs_setBackgroundColor(UIColor.red,for: .highlighted)
CGPoint extensionaPoint.cs_distance(toPoint: bPoint)
CGPoint.cs_distance(fromPoint: aPoint,toPoint: bPoint)
DispatchQueue extensionDispatchQueue.cs_delay(2) {
print("delay action")
}
DispatchQueue.cs_global {
print("global action")
DispatchQueue.cs_main {
print("main action")
}
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- oracle导入导出 dmp文件
- nand_get_flash_type: second ID read did not match 0e,ec
- iOS使用UIGestureRecognizer识别手势
- react闲谈——react@15.5.0发布更新说明
- c# – Visual Studio 2010中所有注释的文档
- 依赖 – Liferay:是否可以通过portlet定义初始化依赖?
- actionscript-3 – Flash:使用一个eventlistener监听一个类
- c# – DataGridView的魔力
- objective-c – UIPasteboard限制
- 《Swift NSDictionary 的详细使用和部分方法介绍 和 哈希表