Skip to content

Commit 11b3f1d

Browse files
author
coderchan
committed
FixBug
1 parent a6e88ef commit 11b3f1d

File tree

11 files changed

+312
-62
lines changed

11 files changed

+312
-62
lines changed

Example/Example/ViewController.swift

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,38 @@
55
// Created by CoderChan on 2025/3/18.
66
//
77

8-
import UIKit
8+
//import UIKit
99
import SwiftlyUI
1010

1111

12-
#if canImport(SwiftUI) && DEBUG
13-
import SwiftUI
14-
struct ViewControllerPreview: PreviewProvider {
15-
static var previews: some View {
16-
UIViewControllerPreview {
17-
UINavigationController(rootViewController: ViewController())
18-
}.edgesIgnoringSafeArea(.all)
19-
.previewDevice("iPhone 16 Pro")
20-
}
21-
}
22-
//struct ViewPreview: PreviewProvider {
12+
//#if canImport(SwiftUI) && DEBUG
13+
//import SwiftUI
14+
//struct ViewControllerPreview: PreviewProvider {
2315
// static var previews: some View {
24-
// UIViewPreview {
25-
// ViewController().view
16+
// UIViewControllerPreview {
17+
// UINavigationController(rootViewController: ViewController())
2618
// }.edgesIgnoringSafeArea(.all)
2719
// .previewDevice("iPhone 16 Pro")
2820
// }
2921
//}
30-
31-
#endif
22+
////struct ViewPreview: PreviewProvider {
23+
//// static var previews: some View {
24+
//// UIViewPreview {
25+
//// ViewController().view
26+
//// }.edgesIgnoringSafeArea(.all)
27+
//// .previewDevice("iPhone 16 Pro")
28+
//// }
29+
////}
30+
//
31+
//#endif
3232
class ViewController: UIViewController {
33-
deinit {
34-
print("deinit")
35-
}
36-
37-
33+
deinit { print("deinit") }
3834
override func viewDidLoad() {
3935
super.viewDidLoad()
4036
view.backgroundColor = .white
4137
print("viewDidLoad")
4238

43-
test7()
39+
test4()
4440
}
4541

4642
func test8() {
@@ -54,7 +50,7 @@ class ViewController: UIViewController {
5450
func test7() {
5551
let swt = UISwitch()
5652
.center(to: view)
57-
.sizeScale(0.5)
53+
.scaleEffect(0.5)
5854
.onTintColor(.orange)
5955
.thumbTintColor(.red)
6056
.onAction { (swt: UISwitch) in
@@ -107,6 +103,7 @@ class ViewController: UIViewController {
107103
.imageName("navi_back_black", state: .normal)
108104
// .frame(width: 44, height: 44)
109105
.frame(size: CGSize(width: 44, height: 44))
106+
.scaleEffect(0.3, anchor: .center)
110107
.onAction(target: self, action: { (vc: ViewController, btn: UIButton) in
111108
vc.onBackButtonAction()
112109
btn.alpha = 0.5
@@ -115,9 +112,9 @@ class ViewController: UIViewController {
115112
return button
116113
}()
117114
func animation() {
118-
self.backButton.constraint(.bottom)?.constant = -90
119-
withAnimation {
120-
self.view.layoutIfNeeded()
115+
116+
SwiftlyUI.withAnimation {
117+
self.backButton.scaleEffect(0.8, anchor: .bottomLeading)
121118
}
122119
print("animation")
123120
}
@@ -153,6 +150,11 @@ class ViewController: UIViewController {
153150
}
154151
func test4() {
155152
view.addSubview(backButton)
153+
let bg = UIView()
154+
.backgroundColor(.orange.opacity(0.5))
155+
.frame(size: CGSize(width: 44, height: 44))
156+
.center(to: backButton)
157+
view.insertSubview(bg, at: 0)
156158

157159
// let image = UIImage.gradient(colors: [.brown, .clear], direction: .leftToRight, size: CGSize(width: 100, height: 40))
158160
// let imageView = UIImageView()

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SwiftlyUI/Source/Core/UISwitch+SwiftlyUI.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ import UIKit
1010

1111
public extension UISwitch {
1212

13-
/// default is 1
14-
@discardableResult
15-
func sizeScale(_ scale: CGFloat = 1) -> Self {
16-
self.transform(CGAffineTransform(scaleX: scale, y: scale))
17-
return self
18-
}
19-
2013
@discardableResult
2114
func onTintColor(_ color: UIColor?) -> Self {
2215
self.onTintColor = color

SwiftlyUI/Source/Core/UITextField+SwiftlyUI.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ public extension UITextField {
9595
return self
9696
}
9797

98+
@discardableResult
99+
func attributedPlaceholder(_ attributedText: NSAttributedString) -> Self {
100+
self.attributedPlaceholder = attributedText
101+
return self
102+
}
103+
98104
@discardableResult
99105
func keyboardType(_ type: UIKeyboardType) -> Self {
100106
self.keyboardType = type
@@ -119,6 +125,12 @@ public extension UITextField {
119125
return self
120126
}
121127

128+
@discardableResult
129+
func adjustsFontSizeToFitWidth(_ adjusts: Bool) -> Self {
130+
self.adjustsFontSizeToFitWidth = adjusts
131+
return self
132+
}
133+
122134
@discardableResult
123135
func minimumFontSize(_ size: CGFloat) -> Self {
124136
self.minimumFontSize = size
@@ -136,6 +148,49 @@ public extension UITextField {
136148
self.borderStyle = style
137149
return self
138150
}
151+
152+
@discardableResult
153+
func delegate(_ delegate: UITextFieldDelegate?) -> Self {
154+
self.delegate = delegate
155+
return self
156+
}
157+
158+
@discardableResult
159+
func attributedText(_ attributedText: NSAttributedString) -> Self {
160+
self.attributedText = attributedText
161+
updatePlaceholderVisibility()
162+
return self
163+
}
164+
165+
@discardableResult
166+
func defaultTextAttributes(_ attributes: [NSAttributedString.Key: Any]) -> Self {
167+
self.defaultTextAttributes = attributes
168+
return self
169+
}
170+
171+
@discardableResult
172+
func background(_ image: UIImage?) -> Self {
173+
self.background = image
174+
return self
175+
}
176+
177+
@discardableResult
178+
func disabledBackground(_ image: UIImage?) -> Self {
179+
self.disabledBackground = image
180+
return self
181+
}
182+
183+
@discardableResult
184+
func allowsEditingTextAttributes(_ allows: Bool) -> Self {
185+
self.allowsEditingTextAttributes = allows
186+
return self
187+
}
188+
189+
@discardableResult
190+
func typingAttributes(_ attributes: [NSAttributedString.Key: Any]) -> Self {
191+
self.typingAttributes = attributes
192+
return self
193+
}
139194
}
140195

141196
// MARK: - Action

0 commit comments

Comments
 (0)