UIKitX 版本 0.1.10

UIKitX 版本 0.1.10

Ali AlNaghmoush 维护。



UIKitX 版本 0.1.10

  • alialnaghmoush

欢迎使用 UIKitX,一个简单又强大的 UI/UX 框架,易于使用以创建美观的应用程序。

Language: Swift 2, 3, 4 and 5 Platform Release License

特性

  • 干净的 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)
        
    }