ViewGenerator generates view code from variable name automatically when you create view by code in iOS development
- Xcode 10.3 or greater
- Swift 5.0 or greator
-
Install ViewGenerator from AppStore
-
Enable ViewGenerator
System Preferences
→Extensions
- Switch on
Xcode Source Editor
checkbox
- Input variable name
⚠Important⚠ : variable name must be included class name withoutUI
as suffix. (e.g.hogeView
,hogeLabel
, etc.)
Please check Support View List bellow - Select variable name
Editor
→ViewGenerator
→Generate View Code
- Generated⚒
I strongly recommend that you register Generate View Code
Command to shortcut
Xcode Preferences
→KeyBindings
- Input
ViewGenerator
in Search - Register shortcut
GIF | |
---|---|
select |
GIF | |
---|---|
not_select | |
select |
Default access modifier is private . if you change access modifier, open viewgenerator app and then select access modifier that you want to select
For example, if variable name prefix is hoge
, it is generated as bellow
hogeView
private let hogeView: UIView = {
let hogeView = UIView(frame: .zero)
hogeView.translatesAutoresizingMaskIntoConstraints = false
return hogeView
}()
hogeButton
private let hogeButton: UIButton = {
let hogeButton = UIButton(frame: .zero)
hogeButton.translatesAutoresizingMaskIntoConstraints = false
return hogeButton
}()
hogeTableView
private let hogeTableView: UITableView = {
let hogeTableView = UITableView(frame: .zero)
hogeTableView.translatesAutoresizingMaskIntoConstraints = false
return hogeTableView
}()
hogehoge
private let hogehoge: _InputTypeName_ = {
let hogehoge = _InputTypeName_(frame: .zero)
hogehoge.translatesAutoresizingMaskIntoConstraints = false
return hogehoge
}()
View |
---|
UISwitch |
UIActivityIndicatorView |
UIButton |
UICollectionView |
UIControl |
UIDatePicker |
UIImageView |
UILabel |
UINavigationBar |
UIPageControl |
UIPickerView |
UIProgressView |
UIScrollView |
UISearchBar |
UISegmentedControl |
UISlider |
UIStackView |
UIStepper |
UITabBar |
UITableView |
UITextField |
UITextView |
UIToolbar |
UIView |
UIVisualEffectView |
If you input variable name that doesn't correspond to the support view list, type name is input as _InputTypeName_
automatically.
If you discover problem or have opinions, please let me know through Github issues💁♂️
funzin
ViewGenerator is available under the MIT license. See the LICENSE file for more info.