File tree 4 files changed +30
-15
lines changed
4 files changed +30
-15
lines changed Original file line number Diff line number Diff line change 22
22
<rect key =" frame" x =" 67" y =" 238" width =" 240" height =" 128" />
23
23
<autoresizingMask key =" autoresizingMask" flexibleMaxX =" YES" flexibleMaxY =" YES" />
24
24
<color key =" backgroundColor" white =" 1" alpha =" 1" colorSpace =" calibratedWhite" />
25
- <userDefinedRuntimeAttributes >
26
- <userDefinedRuntimeAttribute type =" string" keyPath =" title" value =" This is an overriden title" />
27
- <userDefinedRuntimeAttribute type =" number" keyPath =" price" >
28
- <real key =" value" value =" 2" />
29
- </userDefinedRuntimeAttribute >
30
- <userDefinedRuntimeAttribute type =" string" keyPath =" details" value =" This is an overriden details" />
31
- </userDefinedRuntimeAttributes >
32
25
</view >
33
26
</subviews >
34
27
<color key =" backgroundColor" white =" 1" alpha =" 1" colorSpace =" calibratedWhite" />
35
28
<viewLayoutGuide key =" safeArea" id =" 6Tk-OE-BBY" />
36
29
</view >
30
+ <connections >
31
+ <outlet property =" listingView" destination =" XKD-5Y-F7e" id =" iTX-g0-re5" />
32
+ </connections >
37
33
</viewController >
38
34
<placeholder placeholderIdentifier =" IBFirstResponder" id =" dkx-z0-nzr" sceneMemberID =" firstResponder" />
39
35
</objects >
Original file line number Diff line number Diff line change @@ -26,16 +26,15 @@ import UIKit
26
26
27
27
class ViewController : UIViewController {
28
28
29
+ @IBOutlet weak var listingView : ListingView !
30
+
29
31
override func viewDidLoad( ) {
30
32
super. viewDidLoad ( )
31
- // Do any additional setup after loading the view, typically from a nib.
33
+ listingView. title = " Title from View Controller "
34
+ listingView. details = " Details from View Controller "
35
+ listingView. price = 40
36
+ listingView. updateView ( )
32
37
}
33
38
34
- override func didReceiveMemoryWarning( ) {
35
- super. didReceiveMemoryWarning ( )
36
- // Dispose of any resources that can be recreated.
37
- }
38
-
39
-
40
39
}
41
40
Original file line number Diff line number Diff line change @@ -92,14 +92,34 @@ class ListingView: MSAutoView {
92
92
93
93
![ Image] ( https://user-images.githubusercontent.com/24646608/34811485-34100180-f6f5-11e7-9671-44705690d06b.png )
94
94
95
- - You can also override the default values from the storyboard's attributes inspector for the view:
95
+ - You can also override the default values from the storyboard's attributes inspector for the view ( ** Make sure you don't set the attributes in the attribute inspector of the xib or they will override all other values ** ) :
96
96
97
97
![ Image] ( https://user-images.githubusercontent.com/24646608/34811582-a519fe26-f6f5-11e7-8d71-80bb77d8c55f.png )
98
98
99
99
This is the result:
100
100
101
101
![ Image] ( https://user-images.githubusercontent.com/24646608/34811599-c514e92a-f6f5-11e7-9405-e85e7ced94d5.png )
102
102
103
+ - You can also create a reference for the view in the view controller's class and set its values:
104
+
105
+ ``` swift
106
+ class ViewController : UIViewController {
107
+
108
+ @IBOutlet weak var listingView: ListingView!
109
+
110
+ override func viewDidLoad () {
111
+ super .viewDidLoad ()
112
+ listingView.title = " Title from View Controller"
113
+ listingView.details = " Details from View Controller"
114
+ listingView.price = 40
115
+ listingView.updateView ()
116
+ }
117
+
118
+ }
119
+ ```
120
+
121
+ ![ Image] ( https://user-images.githubusercontent.com/24646608/34811911-7f51df36-f6f7-11e7-9a48-fce96c59d195.png )
122
+
103
123
## Deployment
104
124
105
125
If you want to use the auto view in your own project just copy the AutoView Folder.
You can’t perform that action at this time.
0 commit comments