Skip to content

Commit b718690

Browse files
author
coderchan
committed
Other Views
1 parent 4690fa5 commit b718690

26 files changed

+1219
-3
lines changed

Example/Example/ViewController.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,37 @@ class ViewController: UIViewController {
3333
deinit {
3434
print("deinit")
3535
}
36+
37+
3638
override func viewDidLoad() {
3739
super.viewDidLoad()
3840
view.backgroundColor = .white
3941
print("viewDidLoad")
40-
test4()
41-
test6()
4242

43+
test7()
4344
}
4445

46+
func test8() {
47+
let tableView = UITableView()
48+
let refresh = UIRefreshControl()
49+
.tintColor(.red)
50+
tableView.refreshControl = refresh
51+
52+
}
53+
// @available(iOS 14.0, *)
54+
func test7() {
55+
let swt = UISwitch()
56+
.center(to: view)
57+
.sizeScale(0.5)
58+
.onTintColor(.orange)
59+
.thumbTintColor(.red)
60+
.onAction { (swt: UISwitch) in
61+
print("switch is \(swt.isOn)")
62+
}
63+
64+
view.addSubview(swt)
65+
print("swt.frame:\(swt.frame)")
66+
}
4567
func test6() {
4668
let array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
4769
let scrollView = VScrollView {

Example/Pods/Pods.xcodeproj/project.pbxproj

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

SwiftlyUI/Source/Core/UIButton+SwiftlyUI.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// Created by CoderChan on 2025/2/27.
66
//
7+
78
#if canImport(UIKit)
89
import UIKit
910

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
//
2+
// UICollectionView+SwiftlyUI.swift
3+
// Pods
4+
//
5+
// Created by CoderChan on 2025/6/5.
6+
//
7+
8+
#if canImport(UIKit)
9+
import UIKit
10+
11+
public extension UICollectionView {
12+
13+
@discardableResult
14+
func delegate(_ delegate: UICollectionViewDelegate?) -> Self {
15+
self.delegate = delegate
16+
return self
17+
}
18+
19+
@discardableResult
20+
func dataSource(_ dataSource: UICollectionViewDataSource?) -> Self {
21+
self.dataSource = dataSource
22+
return self
23+
}
24+
25+
@discardableResult
26+
func collectionViewLayout(_ layout: UICollectionViewLayout) -> Self {
27+
self.collectionViewLayout = layout
28+
return self
29+
}
30+
31+
@discardableResult
32+
func prefetchDataSource(_ prefetchDataSource: UICollectionViewDataSourcePrefetching?) -> Self {
33+
self.prefetchDataSource = prefetchDataSource
34+
return self
35+
}
36+
37+
@discardableResult
38+
func prefetchingEnabled(_ enabled: Bool) -> Self {
39+
self.isPrefetchingEnabled = enabled
40+
return self
41+
}
42+
43+
@discardableResult
44+
func dragDelegate(_ dragDelegate: UICollectionViewDragDelegate?) -> Self {
45+
self.dragDelegate = dragDelegate
46+
return self
47+
}
48+
49+
@discardableResult
50+
func dropDelegate(_ dropDelegate: UICollectionViewDropDelegate?) -> Self {
51+
self.dropDelegate = dropDelegate
52+
return self
53+
}
54+
55+
@discardableResult
56+
func dragInteractionEnabled(_ enabled: Bool) -> Self {
57+
self.dragInteractionEnabled = enabled
58+
return self
59+
}
60+
61+
@discardableResult
62+
func reorderingCadence(_ cadence: UICollectionView.ReorderingCadence) -> Self {
63+
self.reorderingCadence = cadence
64+
return self
65+
}
66+
67+
#if compiler(>=5.7)
68+
@available(iOS 16.0, *)
69+
@discardableResult
70+
func selfSizingInvalidation(_ selfSizingInvalidation: UICollectionView.SelfSizingInvalidation) -> Self {
71+
self.selfSizingInvalidation = selfSizingInvalidation
72+
return self
73+
}
74+
#endif
75+
76+
@discardableResult
77+
func backgroundView(_ backgroundView: UIView?) -> Self {
78+
self.backgroundView = backgroundView
79+
return self
80+
}
81+
82+
@discardableResult
83+
func allowsSelection(_ selection: Bool) -> Self {
84+
self.allowsSelection = selection
85+
return self
86+
}
87+
88+
@discardableResult
89+
func allowsMultipleSelection(_ multipleSelection: Bool) -> Self {
90+
self.allowsMultipleSelection = multipleSelection
91+
return self
92+
}
93+
94+
#if compiler(>=5.3)
95+
@available(iOS 14.0, *)
96+
@discardableResult
97+
func allowsSelectionDuringEditing(_ editing: Bool) -> Self {
98+
self.allowsSelectionDuringEditing = editing
99+
return self
100+
}
101+
@available(iOS 14.0, *)
102+
@discardableResult
103+
func allowsMultipleSelectionDuringEditing(_ multipleSelection: Bool) -> Self {
104+
self.allowsMultipleSelectionDuringEditing = multipleSelection
105+
return self
106+
}
107+
108+
@available(iOS 14.0, *)
109+
@discardableResult
110+
func selectionFollowsFocus(_ follows: Bool) -> Self {
111+
self.selectionFollowsFocus = follows
112+
return self
113+
}
114+
@available(iOS 14.0, *)
115+
@discardableResult
116+
func editing(_ isEditing: Bool) -> Self {
117+
self.isEditing = isEditing
118+
return self
119+
}
120+
#endif
121+
122+
#if compiler(>=5.5)
123+
@available(iOS 15.0, *)
124+
@discardableResult
125+
func allowsFocus(_ allows: Bool) -> Self {
126+
self.allowsFocus = allows
127+
return self
128+
}
129+
130+
@available(iOS 15.0, *)
131+
@discardableResult
132+
func allowsFocusDuringEditing(_ allows: Bool) -> Self {
133+
self.allowsFocusDuringEditing = allows
134+
return self
135+
}
136+
#endif
137+
138+
@discardableResult
139+
func remembersLastFocusedIndexPath(_ remembers: Bool) -> Self {
140+
self.remembersLastFocusedIndexPath = remembers
141+
return self
142+
}
143+
144+
145+
146+
}
147+
148+
#endif
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//
2+
// UICollectionViewCell+SwiftlyUI.swift
3+
// Pods
4+
//
5+
// Created by CoderChan on 2025/6/5.
6+
//
7+
8+
#if canImport(UIKit)
9+
import UIKit
10+
11+
12+
public extension UICollectionViewCell {
13+
@discardableResult
14+
func backgroundView(_ view: UIView?) -> UICollectionViewCell {
15+
self.backgroundView = view
16+
return self
17+
}
18+
19+
#if compiler(>=5.3)
20+
@available(iOS 14.0, *)
21+
@discardableResult
22+
func automaticallyUpdatesContentConfiguration(_ updates: Bool) -> Self {
23+
self.automaticallyUpdatesContentConfiguration = updates
24+
return self
25+
}
26+
27+
@available(iOS 14.0, *)
28+
@discardableResult
29+
func automaticallyUpdatesBackgroundConfiguration(_ updates: Bool) -> Self {
30+
self.automaticallyUpdatesBackgroundConfiguration = updates
31+
return self
32+
}
33+
#endif
34+
35+
@discardableResult
36+
func selected(_ selected: Bool) -> Self {
37+
self.isSelected = selected
38+
return self
39+
}
40+
41+
@discardableResult
42+
func highlighted(_ highlighted: Bool) -> Self {
43+
self.isHighlighted = highlighted
44+
return self
45+
}
46+
47+
@discardableResult
48+
func selectedBackgroundView(_ view: UIView?) -> Self {
49+
self.selectedBackgroundView = view
50+
return self
51+
}
52+
53+
#if compiler(>=5.3)
54+
@available(iOS 14.0, *)
55+
@discardableResult
56+
func contentConfiguration(_ configuration: UIContentConfiguration) -> Self {
57+
self.contentConfiguration = configuration
58+
return self
59+
}
60+
61+
@available(iOS 14.0, *)
62+
@discardableResult
63+
func backgroundConfiguration(_ configuration: UIBackgroundConfiguration?) -> Self {
64+
self.backgroundConfiguration = configuration
65+
return self
66+
}
67+
#endif
68+
#if compiler(>=5.5)
69+
@available(iOS 15.0, *)
70+
@discardableResult
71+
func configurationUpdateHandler(_ handler: UICollectionViewCell.ConfigurationUpdateHandler?) -> Self {
72+
self.configurationUpdateHandler = handler
73+
return self
74+
}
75+
#endif
76+
}
77+
78+
79+
#endif

0 commit comments

Comments
 (0)