What is LCSlideToUnlock?
LCSlideToUnlock is a simple slide to unlock iOS UI component.
Requirements
- iOS 13+
- Xcode 11+
- Swift 5.1+
Screencast from our Demo
Effect of collection
- Using enumerations to define
LCSlideToUnlock
animation types
/// 动画方向
///
/// - horizontal: 水平
/// - vertical: 垂直
/// - diagonalUp: 对角线往上
/// - diagonalDown: 对角线往下
public enum AnimationDirection {
case horizontal
case vertical
case diagonalUp
case diagonalDown
}
Picture Demo
![]() |
![]() |
![]() |
![]() |
---|---|---|---|
horizontal |
vertical |
diagonalUp |
diagonalDown |
Attribute
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 ) |
Example:
import UIKit
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)
}
}