StfalconSwiftExtensions 0.17

StfalconSwiftExtensions 0.17

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新版本2017年4月
SwiftSwift版本3.0
SPM支持SPM

Victor Amelin维护。



  • Viktor Amelin

SwiftExtensions

SwiftExtension是一系列我们正在Stfalcon使用的有用扩展。

  1. DeviceType: modelName返回当前设备的名称。
  2. Dispatch: 有一个once函数,可以用来替代旧的dispatch_once C函数。
  3. MutableData: 有一个有用的扩展appendString(_ string: String)
  4. OperatorOverloading: 如其名所示,是一组针对数字数组、CGRect、CGPoint和CGSize的重载。
  5. Realm: 有扩展以与Realm(https://realm.io)一起工作,并提供RealmHelper,它可以从Realm获取object并删除所有内容。
  6. UILabel: 包含一个方便设置行间距的函数setTextWithLineSpacing(text: String, lineHeight: CGFloat),如果它不同于标签字体的行间距则很有用;一个允许检测范围中子字符串框架的函数boundingRectForCharacterRange(range: NSRange),这在需要使某些文本可点击时很有用。
  7. UIScrollView: 有一个calculateContentSize(offset: CGFloat, font: UIFont)方法,它计算UIScrollView内UILabel的高度。
  8. UIView: 有一个gradientSublayer(colorA: UIColor = UIColor.red, colorB: UIColor = UIColor.green),它可以用来创建渐变按钮或其他UIView;addDashedLine(startPoint: CGPoint, endPoint: CGPoint, color: UIColor, lineWidth: CGFloat, step: Int)很有用于创建虚线;snapshotImage() -> UIImage?返回ui的UIImage快照,以及snapshotImageView() -> UIImageView?返回带有ui快照的UIImageView。
  9. UIViewController: 有一个topViewController(_ base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController?方法,它返回顶层视图控制器。
  10. 字符串扩展包含一组函数,允许与Swift字符串、子字符串、类似NSString的子字符串范围一起工作。