测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新发布 | 2017年11月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✓ |
由 gwangbeom 维护。
Windless 可以轻松实现不可见的布局加载视图。
![]() |
![]() |
![]() |
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
Windless 4.0+ 需要 CocoaPods 1.1+ 来构建。
要将 Windless 集成到您的 Xcode 项目中,使用 CocoaPods,在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Windless', '~> 0.1.5'
end
然后,运行以下命令
$ pod install
Carthage 是一个去中心化的依赖管理器,它会构建您的依赖并提供二进制框架。
您可以使用以下命令通过 Homebrew 安装 Carthage
$ brew update
$ brew install carthage
要将 Windless 集成到您的 Xcode 项目中,使用 Carthage,在您的 Cartfile
中指定它
github "Interactive-Studio/Windless" ~> 0.1.5
运行 carthage update
来构建框架并将构建的 Windless.framework
拖到您的 Xcode 项目中。
如果您不想使用上述任一依赖管理器,您可以手动将 Windless 集成到项目中。
import Windless
class ViewController: UIViewController {
lazy var contentsView = UIView()
var subView1 = UIView()
var subView2 = UIView()
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(contentsView)
contentsView.addSubview(subView1)
contentsView.addSubview(subView2)
// start
contentsView.windless
.setupWindlessableViews([subView1, subView2])
.start()
// stop
contentsView.windless.end()
}
}
如果您使用 Storyboard 或 xib,您只需在视图中将您想要显示为假的视图的 isWindlessable
标志设置为 true,并且不需要将视图通过 setupWindlessableViews
方法传递。
import Windless
class ViewController: UIViewController {
@IBOutlet weak var contentsView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
contentsView.windless.start()
}
}
根据 lineHeight
值和 spacing
值,UILabel 和 UITextView 在 Windless 动画运行时将重建布局。
public protocol CanBeMultipleLines {
var lineHeight: CGFloat { get set }
var spacing: CGFloat { get set }
}
Windless 有几个可自定义的选项。
public class WindlessConfiguration {
/// The direction of windless animation. Defaults to rightDiagonal.
public var direction: WindlessDirection = .rightDiagonal
/// The speed of windless animation. Defaults to 1.
public var speed: Float = 1
/// The duration of the fade used when windless begins. Defaults to 0.
public var beginTime: CFTimeInterval = 0
/// The time interval windless in seconds. Defaults to 4.
public var duration: CFTimeInterval = 4
/// The time interval between windless in seconds. Defaults to 2.
public var pauseDuration: CFTimeInterval = 2
/// gradient animation timingFunction default easeOut
public var timingFuction: CAMediaTimingFunction = .easeOut
/// gradient layer center color default .lightGray
public var animationLayerColor: UIColor = .lightGray
/// Mask layer background color default .groupTableViewBackground
public var animationBackgroundColor: UIColor = .groupTableViewBackground
/// The opacity of the content while it is windless. Defaults to 0.8.
public var animationLayerOpacity: CGFloat = 0.8
}
要设置选项,请使用下面的 apply 方法。
import Windless
class ViewController: UIViewController {
@IBOutlet weak var contentsView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
contentsView.windless
.apply {
$0.beginTime = 1
$0.pauseDuration = 2
$0.duration = 3
$0.animationLayerOpacity = 0.5
}
.start()
}
}
如果您想了解更详细的用法,请参阅示例。
isWindlessable
值确定加载视图的外观。下面的图片显示了根据 isWindlessable
值加载屏幕的外观。
isWindlessable
=🌀
配置 | 结果 |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Windless 在 MIT 许可证下发布。有关详情请参阅 LICENSE。