TVButton 可在 UIButton 控件上重新创建类似于在 Apple TV 上看到的美丽视差效果。长按或拖动即可触发效果。要使用视差效果,您至少需要两/三层具有相同尺寸的图像。以下是一个具体实例:
let bg = TVButtonLayer(image: UIImage(named: "TVBG.png")!)
let pattern = TVButtonLayer(image: UIImage(named: "TVBtnPattern.png")!)
let top = TVButtonLayer(image: UIImage(named: "TVbtnTop.png")!)
tvButton.layers = [background, pattern, top]
然后,您可以通过更改以下属性来自定义视差效果强度:
tvButton.parallaxIntensity = 1.3
• https://github.com/marmelroy/TVButton
TKRubberIndicator是Swift制作的库,它可在应用程序中添加橡胶动画页面控件。要使用它,您需要首先导入TKRubberPageControl框架。然后,您需要将以下代码添加到控制器中:
override func viewDidLoad() {
super.viewDidLoad()
page.center = self.view.center
page.valueChange = {(num) -> Void in
print("Closure : Page is \(num)")
}
page.addTarget(self, action: "targetActionValueChange:", forControlEvents: UIControlEvents.ValueChanged)
self.view.addSubview(page)
page.numberOfpage = 2
}
@IBAction func pageCountChange(sender: UISegmentedControl) {
page.numberOfpage = (sender.selectedSegmentIndex + 1) * 2
}
func targetActionValueChange(page:TKRubberIndicator){
print("Target-Action : Page is \(page.currentIndex)")
}
• https://github.com/TBXark/TKRubberIndicator
只需要几行代码,DimensionsPickerView 就可让您添加一个漂亮的视图,该视图可用于测量数据输入。可通过以下方式自定义占位符单位,字体颜色,间距和边框颜色/宽度:
sizePickerView.textFieldConfigureBlock = { index, field in
switch index {
case 0:
field.placeholder = "w"
case 1:
field.placeholder = "h"
default:
break
}
}
sizePickerView.pickerFieldConfigureBlock = { field in
field.text = "m"
}
sizePickerView.tintColor = UIColor.red
sizePickerView.spacingBetweenValueFields = 0
sizePickerView.spacingBetweenUnitAndValues = 30
sizePickerView.layer.cornerRadius = 5
sizePickerView.layer.borderColor = UIColor.white.cgColor
sizePickerView.layer.borderWidth = 1.5
• https://github.com/hussc/DimensionsPickerView
TransitionButton是一个用于添加带有加载和过渡动画的 UIButton 的库。首先,TransitionButton 是 UIButton 的子类。TransitionButton 还添加了两个主要方法:
• startAnimation():调用时将开始使用加载微调器为按钮设置动画 • stopAnimation():调用时将停止对按钮进行动画处理
• https://github.com/AladinWay/TransitionButton
Sliders是完全使用 SwiftUI 构建的库。它使您可以在 iOS,macOS 和 Mac Catalyst 上创建可自定义的水平和垂直滑块。在个性化设置中,可以设置:简单的渐变值滑块样式;多值跟踪;复杂范围滑块样式;复杂点滑块样式
• https://github.com/SwiftUIExtensions/Sliders