LTHExtensions 1.2.0

LTHExtensions 1.2.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2016年12月
SwiftSwift 版本3.0
SPM支持 SPM

Roland Leth 维护。



  • 作者:]
  • Roland Leth

String

"123"[2] // => 3
"123".length // => 3
"123" * 2 // => 123123
"123".containsString("12") // => true
"123".containsString("13") // => false
"123".isInt // => true; "123.0".isInt => false
"123".isFloat // => true; "123.0".isFloat => true; "123..0".isFloat => false
"123".toFloat // => 123.0
"123".toDouble // => 123.0
"123".toInt // => 123
"123".toBool // => true
"AvenirNext-Regular".uifont(16) // => UIFont(name: "AvenirNext-Regular", size: 16)
// If no size is supplied, UIFont.systemFontSize() is used
"myImage.png".uiimage() // => UIImage(named: "myImage.png")

Int

5.isEven // => false
5.isOdd // => true
5.squared // => 25
5.square() // => 25
5.toFloat // => 5.0
5.times { print("12345") } // => 1234512345
5.degreesToRadians // => 0.0872664600610733

Float

5.0.degreesToRadians // => 0.0872664600610733

Array

[1, 2].first // => 1
[1, 2].last // => 2
[1, 2] << 3 // => [1, 2, 3]
[1, 2] + 3 // => [1, 2, 3]
[1, 2] << "3", [1, 2] + "3" // different types => error

Dictionary

[1: 1] += [2: 2] // => [1: 1, 2: 2]
[1: 1] << [2: 2] // => [1: 1, 2: 2]
[1: 1] + [2: 2] // => [1: 1, 2: 2]
[1: 1] << [2: "2"], [1: 1] += [2: "2"], [1: 1] + [2: "2"] // different types => error

UIView

view << view1 // view.subviews = [view1]
view[0] // => view1

AnyObject

var s: String? // Works with any Optional
s ||= "1" // => 1
s ||= "2" // => 1
s ||= 2 // different types => error

UIImage

UIImage.imageWithColor(UIColor.redColor())
UIImage(named: "my-image").tintedImageWithColor(UIColor.redColor(), blendMode: kCGBlendModeHue)

许可证

许可协议:MIT。


欢迎向我提问,我会很高兴听到您的意见 @rolandleth 或发送电子邮件至 [email protected]