Skip to content

Commit 447a516

Browse files
author
coderchan
committed
SwiftlyUI V1.4.0
1 parent 06b6860 commit 447a516

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

SwiftlyUI.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SwiftlyUI'
3-
s.version = '1.3.9'
3+
s.version = '1.4.0'
44
s.summary = 'Swift-style declarative UIKit Plus'
55
s.homepage = 'https://github.com/CoderLineChan/SwiftlyUI'
66
s.license = { :type => 'MIT', :file => 'LICENSE' }

SwiftlyUI/Source/Core/UIView+SwiftlyUI.swift

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public extension UIView {
4545
/// SwiftlyUI - 拉伸UI
4646
public final class UISpacer: UIView {
4747
/// SwiftlyUI - 初始化一个UISpacer
48-
init(_ axis: NSLayoutConstraint.Axis) {
48+
public init(_ axis: NSLayoutConstraint.Axis) {
4949
super.init(frame: .zero)
5050
self.axis(axis)
5151
}
5252
/// SwiftlyUI - 初始化一个UISpacer
53-
init(axis: NSLayoutConstraint.Axis) {
53+
public init(axis: NSLayoutConstraint.Axis) {
5454
super.init(frame: .zero)
5555
self.axis(axis)
5656
}
@@ -70,47 +70,45 @@ public final class UISpacer: UIView {
7070

7171
/// SwiftlyUI - 设置最小宽度
7272
@discardableResult
73-
func minWidth(_ value: CGFloat) -> Self {
73+
public func minWidth(_ value: CGFloat) -> Self {
7474
frame(minWidth: value)
7575
return self
7676
}
7777

7878
/// SwiftlyUI - 设置最小高度
7979
@discardableResult
80-
func minHeight(_ value: CGFloat) -> Self {
80+
public func minHeight(_ value: CGFloat) -> Self {
8181
frame(minHeight: value)
8282
return self
8383
}
8484

8585
/// SwiftlyUI - 设置最大宽度
8686
@discardableResult
87-
func maxWidth(_ value: CGFloat) -> Self {
87+
public func maxWidth(_ value: CGFloat) -> Self {
8888
frame(maxWidth: value)
8989
return self
9090
}
9191

9292
/// SwiftlyUI - 设置最大高度
9393
@discardableResult
94-
func maxHeight(_ value: CGFloat) -> Self {
94+
public func maxHeight(_ value: CGFloat) -> Self {
9595
frame(maxHeight: value)
9696
return self
9797
}
9898

99-
/// SwiftlyUI - 废弃
100-
@available(*, unavailable, message: "Use init(axis:) or init(_ axis:) instead.")
101-
public convenience init() {
102-
fatalError("SwiftlyUI UISpacer cannot be initialized with init(). Use init(axis:) or init(_ axis:) instead.")
99+
/// SwiftlyUI - Use init(axis:) instead.
100+
private convenience init() {
101+
fatalError("UISpacer cannot be initialized with init(). Use init(axis:) instead.")
103102
}
104-
105-
/// SwiftlyUI - 废弃
106-
@available(*, unavailable, message: "Use init(axis:) instead.")
107-
public override init(frame: CGRect) {
108-
fatalError("SwiftlyUI UISpacer can not user init(frame:)")
103+
104+
/// SwiftlyUI - Use init(axis:) instead.
105+
private override init(frame: CGRect) {
106+
super.init(frame: frame)
109107
}
110108

111-
/// SwiftlyUI - 废弃
112-
required init?(coder: NSCoder) {
113-
fatalError("SwiftlyUI init(coder:) has not been implemented")
109+
/// SwiftlyUI - Use init(axis:) instead.
110+
internal required init?(coder: NSCoder) {
111+
super.init(coder: coder)
114112
}
115113
}
116114

@@ -162,7 +160,6 @@ public extension UIView {
162160
/// - edge: 设置UIEdgeInsets
163161
@discardableResult
164162
@objc func layoutMargins(_ edge: UIEdgeInsets) -> Self {
165-
translatesAutoresizingMaskIntoConstraints = false
166163
layoutMargins = edge
167164
return self
168165
}
@@ -356,8 +353,8 @@ public extension UIView {
356353
return self
357354
}
358355

359-
/// SwiftlyUI - 在顶部添加Views
360-
/// 在View的顶部 覆盖Views,默认没有布局
356+
/// SwiftlyUI - 添加子视图
357+
/// 添加子视图,默认没有布局
361358
@discardableResult
362359
func overlay(@SwiftlyUIBuilder content: () -> [UIView]) -> Self {
363360
let subviews = content()
@@ -367,6 +364,17 @@ public extension UIView {
367364
return self
368365
}
369366

367+
/// SwiftlyUI - 添加子视图
368+
/// 添加子视图,默认没有布局
369+
@discardableResult
370+
func addSubViews(@SwiftlyUIBuilder content: () -> [UIView]) -> Self {
371+
let subviews = content()
372+
subviews.forEach { sub in
373+
addSubview(sub)
374+
}
375+
return self
376+
}
377+
370378
/// SwiftlyUI - 设置阴影
371379
@discardableResult
372380
func shadow(

0 commit comments

Comments
 (0)