Skip to content

Commit 8d6ca9f

Browse files
author
coderchan
committed
SwiftlyUI V1.1.10
1 parent deff955 commit 8d6ca9f

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

Example/Example/ViewController.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ class ViewController: UIViewController {
3333

3434
}
3535

36+
func test3() {
37+
let view1 = UIView()
38+
.backgroundColor(.red)
39+
.frame(width: 100, height: 100)
40+
.centerX(to: view)
41+
.centerY(to: view)
42+
view.addSubview(view1)
43+
44+
let view2 = UIView()
45+
.backgroundColor(.blue)
46+
47+
48+
view1.addSubview(view2)
49+
view2.leadingToSuper(offset: 10)
50+
view2.trailingToSuper(offset: 20)
51+
view2.topToSuper(offset: 0)
52+
view2.bottomToSuper(offset: 0)
53+
// view2.fillSuper(edge: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 20))
54+
}
3655

3756
func onBackButtonAction() {
3857
let vc = ViewController()

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.1.9'
3+
s.version = '1.1.10'
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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public extension UIView {
586586
func bottomToSuper(isMargins: Bool = false, offset: CGFloat = 0) -> Self {
587587
if let superview = superview {
588588
addNewConstraint(
589-
bottomAnchor.constraint(equalTo: isMargins ? superview.layoutMarginsGuide.bottomAnchor : superview.bottomAnchor, constant: offset),
589+
bottomAnchor.constraint(equalTo: isMargins ? superview.layoutMarginsGuide.bottomAnchor : superview.bottomAnchor, constant: -offset),
590590
type: .bottom
591591
)
592592
} else {
@@ -611,7 +611,7 @@ public extension UIView {
611611
func bottom(to view: UIView, offset: CGFloat = 0) -> Self {
612612
if view == superview {
613613
addNewConstraint(
614-
bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.bottomAnchor, constant: offset),
614+
bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.bottomAnchor, constant: -offset),
615615
type: .bottom
616616
)
617617
}else {
@@ -646,7 +646,7 @@ public extension UIView {
646646
func bottom(lessThanOrEqualTo view: UIView, offset: CGFloat = 0) -> Self {
647647
if view == superview {
648648
addNewConstraint(
649-
bottomAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.bottomAnchor, constant: offset),
649+
bottomAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.bottomAnchor, constant: -offset),
650650
type: .bottom
651651
)
652652
}else {
@@ -668,7 +668,7 @@ public extension UIView {
668668
func rightToSuper(isMargins: Bool = false, offset: CGFloat = 0) -> Self {
669669
if let superview = superview {
670670
addNewConstraint(
671-
rightAnchor.constraint(equalTo: isMargins ? superview.layoutMarginsGuide.rightAnchor : superview.rightAnchor, constant: offset),
671+
rightAnchor.constraint(equalTo: isMargins ? superview.layoutMarginsGuide.rightAnchor : superview.rightAnchor, constant: -offset),
672672
type: .right
673673
)
674674
} else {
@@ -693,7 +693,7 @@ public extension UIView {
693693
func right(to view: UIView, offset: CGFloat = 0) -> Self {
694694
if view == superview {
695695
addNewConstraint(
696-
rightAnchor.constraint(equalTo: view.layoutMarginsGuide.rightAnchor, constant: offset),
696+
rightAnchor.constraint(equalTo: view.layoutMarginsGuide.rightAnchor, constant: -offset),
697697
type: .right
698698
)
699699
}else {
@@ -706,7 +706,7 @@ public extension UIView {
706706
func right(greaterThanOrEqualTo view: UIView, offset: CGFloat = 0) -> Self {
707707
if view == superview {
708708
addNewConstraint(
709-
rightAnchor.constraint(greaterThanOrEqualTo: view.layoutMarginsGuide.rightAnchor, constant: offset),
709+
rightAnchor.constraint(greaterThanOrEqualTo: view.layoutMarginsGuide.rightAnchor, constant: -offset),
710710
type: .right
711711
)
712712
}else {
@@ -728,7 +728,7 @@ public extension UIView {
728728
func right(lessThanOrEqualTo view: UIView, offset: CGFloat = 0) -> Self {
729729
if view == superview {
730730
addNewConstraint(
731-
rightAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.rightAnchor, constant: offset),
731+
rightAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.rightAnchor, constant: -offset),
732732
type: .right
733733
)
734734
}else {
@@ -750,7 +750,7 @@ public extension UIView {
750750
func trailingToSuper(isMargins: Bool = false, offset: CGFloat = 0) -> Self {
751751
if let superview = superview {
752752
addNewConstraint(
753-
trailingAnchor.constraint(equalTo: isMargins ? superview.layoutMarginsGuide.trailingAnchor : superview.trailingAnchor, constant: offset),
753+
trailingAnchor.constraint(equalTo: isMargins ? superview.layoutMarginsGuide.trailingAnchor : superview.trailingAnchor, constant: -offset),
754754
type: .trailing
755755
)
756756
} else {
@@ -775,7 +775,7 @@ public extension UIView {
775775
func trailing(to view: UIView, offset: CGFloat = 0) -> Self {
776776
if view == superview {
777777
addNewConstraint(
778-
trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor, constant: offset),
778+
trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor, constant: -offset),
779779
type: .trailing
780780
)
781781
}else {
@@ -788,7 +788,7 @@ public extension UIView {
788788
func trailing(greaterThanOrEqualTo view: UIView, offset: CGFloat = 0) -> Self {
789789
if view == superview {
790790
addNewConstraint(
791-
trailingAnchor.constraint(greaterThanOrEqualTo: view.layoutMarginsGuide.trailingAnchor, constant: offset),
791+
trailingAnchor.constraint(greaterThanOrEqualTo: view.layoutMarginsGuide.trailingAnchor, constant: -offset),
792792
type: .trailing
793793
)
794794
}else {
@@ -810,7 +810,7 @@ public extension UIView {
810810
func trailing(lessThanOrEqualTo view: UIView, offset: CGFloat = 0) -> Self {
811811
if view == superview {
812812
addNewConstraint(
813-
trailingAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.trailingAnchor, constant: offset),
813+
trailingAnchor.constraint(lessThanOrEqualTo: view.layoutMarginsGuide.trailingAnchor, constant: -offset),
814814
type: .trailing
815815
)
816816
}else {

0 commit comments

Comments
 (0)