LCSlideToUnlock is a simple slide to unlock iOS UI component.
- iOS 13+
- Xcode 11+
- Swift 5.1+
- Using enumerations to define
LCSlideToUnlock
animation types
/// 动画方向
///
/// - horizontal: 水平
/// - vertical: 垂直
/// - diagonalUp: 对角线往上
/// - diagonalDown: 对角线往下
public enum AnimationDirection {
case horizontal
case vertical
case diagonalUp
case diagonalDown
}
horizontal |
vertical |
diagonalUp |
diagonalDown |
Attribute name | Specific introduction of attributes |
---|---|
textStr |
LCSlideToUnlock of text |
textColor |
LCSlideToUnlock text color |
isEnableAutoreverses |
Whether to turn on and back animation |
shimmerImage |
Gradient picture (You can only set one with shimmerColors ) |
shimmerColors |
The gradient color group (at least two elements, only one with shimmerImage ) |
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
Just add the LCSlideToUnlock
folder to your project.
or use CocoaPods
with Podfile:
pod 'LCSlideToUnlock'
You can use CocoaPods to install LCSlideToUnlock
by adding it to your Podfile:
platform :ios, '12.0'
target '<Your Target Name>' do
use_frameworks!
pod 'LCSlideToUnlock'
end
Then, run the following command:
$ pod install
import UIKit
import LCSlideToUnlock
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
/******* LCSlideToUnlockView *******/
let slideToUnlockView = LCSlideToUnlockView(frame: CGRect(x: 0, y: view.bounds.height - 100, width: view.bounds.width, height: 40))
slideToUnlockView.textStr = "> Slide To Unlock "
slideToUnlockView.textColor = .black
slideToUnlockView.shimmerColors = [.white, .white]
//slideToUnlockView.shimmerImage = UIImage(named: "gradient")
slideToUnlockView.font = UIFont.systemFont(ofSize: 20)
slideToUnlockView.animationDirection = .horizontal
slideToUnlockView.isEnableAutoreverses = false
slideToUnlockView.showFadeWithDuration(4)
view.addSubview(slideToUnlockView)
}
}