欢迎使用 UIKitX,一个简单又强大的 UI/UX 框架,易于使用以创建美观的应用程序。
特性
- 干净的 Swift 5 代码。
- 所有功能最简语法。
- 易于调用 UIView 语法。
- 易于创建或选择阴影。
- 易于创建或选择视差效果。
- 便利的颜色调用。
- 便利的十六进制颜色调用。
- 扩展材料设计颜色。
- 易于创建或选择渐变。
- 轻松创建现代提示系统。
- 轻松编辑和创建布局约束。
- 轻松创建动画。
- 未来还会更多。
安装
UIKitX 可通过 CocoaPods 安装。要安装它,请只需将以下行添加到您的 Podfile 中
pod 'UIKitX', '~> 0.1.10'
用法
UIKitX
模块
导入 import UIKitX
简单
border
语法
简单: border(width: CGFloat, color: UIColor)
border(width: CGFloat, color: UIColor, views: UIView...)
边框使用示例
let x = UIView()
x.border(width: 5, color: .white)
let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
x1.border(width: 5, color: .white, views: x2,x3)
borderWidth
语法
简单: borderWidth(_ set: CGFloat)
borderWidth(_ set: CGFloat, views: UIView...)
边框宽度使用示例
let x = UIView()
x.borderWidth(5)
let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
x1.borderWidth(5, views: x2,x3)
borderColor
语法
简单: borderColor(_ set: UIColor)
borderColor(_ set: UIColor, views: UIView...)
borderColor
示例用法 let x = UIView()
x.borderColor(.purple)
let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
x1.borderColor(.white, views: x2,x3)
cornerEdges
语法
简单:cornerEdges(_ set: CGFloat)
cornerEdges(_ active: Bool) // Active as default is true
cornerEdges(_ set: CGFloat, views: UIView...)
cornerEdges(_ active: Bool, views: UIView...) // Active as default is true
cornerEdges
示例用法 let x = UIView()
x.cornerEdges(13)
let x = UIView()
x.cornerEdges(true)
let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
x1.cornerEdges(8, views: x2,x3)
let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
x1.cornerEdges(true, views: x2,x3)
maskedCorners
语法
简单:maskedCorners(_ set: CACornerMask)
maskedCorners(_ set: CACornerMask, views: UIView...)
选择一个或多个
.top
| .left
| .right
| .bottom
| .topRight
| .topLeft
| .bottomRight
| .bottomLeft
maskedCorners
示例用法 let x = UIView()
x.cornerEdges(10).maskedCorners(.top)
let x = UIView()
x.cornerEdges(20).maskedCorners([.topLeft,.bottomRight])
let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
x1.maskedCorners([.topLeft,.bottomRight], views: x2,x3)
maskView
语法
简单:maskView(_ active: Bool) // Active as default is true
maskView(_ active: Bool = true, views: UIView...) // Active as default is true
maskView
使用示例 let x = UIView()
x.maskView()
let x = UIView()
x.maskView(true, views: x2,x3)
clipView
语法
简单:clipView(_ active: Bool) // Active as default is true
clipView(_ active: Bool, views: UIView...) // Active as default is true
clipView
使用示例 let x = UIView()
x.clipView()
let x = UIView()
x.clipView(false, views: x2,x3)
backColor
语法
简单:backColor(_ set: UIColor)
backColor(_ set: UIColor, views: UIView...)
backColor
使用示例 let x = UIView()
x.backColor(.white)
let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
x1.backColor(.purple, views: x2,x3)
addSubviews
语法
简单:addSubviews(_ views: UIView...)
addSubviews
用法示例 let x1 = UIView()
let x2 = UIView()
let x3 = UIView()
view.addSubviews(x1,x2,x3)
parallax
语法
简单的:parallax(_ set: CGFloat)
parallax(min: CGFloat, max: CGFloat)
parallax(_ strength: ParallaxStrength)
选择强度
.ExtraLow
| .Low
| .Mid
| .High
| .ExtraHigh
parallax
用法示例 let x = UIView()
x.parallax()
let x = UIView()
x.parallax(15)
let x = UIView()
x.parallax(min: -20, max: 35)
let x = UIView()
x.parallax(.High)
shadow
语法
简单的:shadow()
shadow(_ color: UIColor, // As default is .black
_ opacity: Float, // As default is 0.10
_ blur: CGFloat, // As default is 10.0
_ x: CGFloat, // As default is 0.0
_ y: CGFloat) // As default is 8.0
shadow(_ elevation: Elevation)
shadow(_ elevation: Elevation, color: UIColor)
选择阴影
.none
.top1
| .top2
| .top3
| .top4
| .top5
.down1
| .down2
| .down3
| .down4
| .down5
.left1
| .left2
| .left3
| .left4
| .left5
.right1
| .right2
| .right3
| .right4
| .right5
shadow
示例用法 let x = UIView()
x.shadow()
let x = UIView()
x.shadow(.black, 0.10, 10.0, 0.0, 8.0)
let x = UIView()
x.shadow(.down4)
let x = UIView()
x.shadow(.down4, color: .purple)
颜色
方便的 UIColor
语法
颜色: UIColor(r: CGFloat, g: CGFloat, b: CGFloat)
UIColor(r: CGFloat, g: CGFloat, b: CGFloat,_ opacity: CGFloat)
UIColor(red: CGFloat, green: CGFloat, blue: CGFloat)
UIColor(red: CGFloat, green: CGFloat, blue: CGFloat,_ opacity: CGFloat)
方便的 UIColor
示例用法 let x = UIView()
let c = UIColor(r: 218, g: 68, b: 83)
x.backColor(c)
let x = UIView()
let c = UIColor(r: 218, g: 68, b: 83, 0.5)
x.backColor(c)
let x = UIView()
let c = UIColor(red: 102, green: 230, blue: 255)
x.backColor(c)
let x = UIView()
let c = UIColor(red: 102, green: 230, blue: 255, 0.8)
x.backColor(c)
hexColor
语法
颜色: UIColor(_ hex: Hex)
UIColor(_ hex: Hex, alpha: CGFloat?)
十六进制值
hex3: 三位十六进制值
| RGB 定义颜色 #RGB
hex4: 四位十六进制值
| RGBA 定义颜色 #RGBA
hex6: 六位十六进制值
| RGB 定义颜色 #RRGGBB
hex8: 八位十六进制值
| RGBA 定义颜色 #RRGGBBAA
hexColor
示例用法 let x = UIView()
let c = UIColor("#03A9F4")
x.backColor(c)
或无 #
let x = UIView()
let c = UIColor("03A9F4")
x.backColor(c)
let x = UIView()
x.border(width: 5, color: UIColor("03A9F4"))
let x = UIView()
x.shadow(UIColor("#03A9F4", alpha: 0.3))
materialColor
语法
颜色: UIColor.materialColor
hexColor
示例用法 let x = UIView()
x.backColor(.Red500)
let x = UIView()
x.border(width: 5, color: .DeepPurple500)
let x = UIView()
x.shadow(.down4, color: .Teal200)
材质颜色板
渐变
初始化器
语法
渐变: UIGradient(colors: [UIColor])
UIGradient(colors: [UIColor],
start: AxesPoint,
end: AxesPoint,
locations: [NSNumber]?,
cornerEdges: CGFloat,
roundEdges: Bool,
style: CAGradientLayerType)
UIGradient(_ set: Gradients)
UIGradient(_ set: Gradients,
start: AxesPoint,
end: AxesPoint,
locations: [NSNumber]?,
cornerEdges: CGFloat,
roundEdges: Bool,
style: CAGradientLayerType)
属性
渐变: colors: [UIColor]
| start: AxesPoint
| end: AxesPoint
| locations: [NSNumber]?
| cornerEdges: CGFloat
| roundEdges: Bool
| style: CAGradientLayerType
| layerAt: UInt32
渐变
示例用法 let x = UIGradient([.Red400, .Red900])
let x = UIGradient(colors: [.Red400,.Red800], start: .top, end: .bottom, locations: nil, cornerEdges: 20, roundEdges: false, style: .axial)
let x = UIGradient(.warmFlame)
let x = UIGradient(.softBlue, cornerEdges: 20)
let x = UIGradient(.softBlue, start: .top, end: .bottom, locations: nil, cornerEdges: 20, roundEdges: false, style: .axial)
渐变色
渐变:
警报
显示
语法
警报:Alert.show(note: String, status: AlertStatus)
Alert.show(note: String, status: AlertStatus, direction: Direction)
选择状态
成功.success
错误 .error
警告.warning
信息 .info
选择方向
从左到右.ltr
从右到左 .rtl
警报
示例用法 var x = UIButton(type: .system)
view.addSubview(x)
x.fillBottom(20, safeArea: true).height(60)
x.addTarget(self, action: #selector(alarto), for: .touchUpInside)
@objc func alarto() {
Alert.show(note: "Welcome to UIKitX", status: .warning)
}
var x = UIButton(type: .system)
{...}
@objc func alarto() {
Alert.show(note: "مرحبا بكم في يو أي كت أكس", status: .success, direction: .rtl)
}