StfalconSwiftExtensions 0.17× 测试已测试✗ 语言语言 SwiftSwift许可证 MIT 发布最新版本2017年4月 SwiftSwift版本3.0 SPM支持SPM✗由Victor Amelin维护。安装指南×StfalconSwiftExtensions的安装指南您想将以下内容添加到Podfile中:pod 'StfalconSwiftExtensions', '~> 0.17'target 'MyApp' do pod 'StfalconSwiftExtensions', '~> 0.17' end然后在终端或从CocoaPods.app中运行pod install。或者,为了进行测试运行,运行以下命令:pod try StfalconSwiftExtensions查看PodspecGitHub仓库CocoaPods.org上的页面StfalconSwiftExtensions 0.17由Viktor Amelinstfalcon-studio/SwiftExtensionsGitHub仓库 SwiftExtensions SwiftExtension是一系列我们正在Stfalcon使用的有用扩展。 DeviceType: modelName返回当前设备的名称。 Dispatch: 有一个once函数,可以用来替代旧的dispatch_once C函数。 MutableData: 有一个有用的扩展appendString(_ string: String)。 OperatorOverloading: 如其名所示,是一组针对数字数组、CGRect、CGPoint和CGSize的重载。 Realm: 有扩展以与Realm(https://realm.io)一起工作,并提供RealmHelper,它可以从Realm获取object并删除所有内容。 UILabel: 包含一个方便设置行间距的函数setTextWithLineSpacing(text: String, lineHeight: CGFloat),如果它不同于标签字体的行间距则很有用;一个允许检测范围中子字符串框架的函数boundingRectForCharacterRange(range: NSRange),这在需要使某些文本可点击时很有用。 UIScrollView: 有一个calculateContentSize(offset: CGFloat, font: UIFont)方法,它计算UIScrollView内UILabel的高度。 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。 UIViewController: 有一个topViewController(_ base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController?方法,它返回顶层视图控制器。 字符串扩展包含一组函数,允许与Swift字符串、子字符串、类似NSString的子字符串范围一起工作。