README.md
September 14, 2019 · View on GitHub
Overview
ViewGenerator generates view code from variable name automatically when you create view by code in iOS development
Download
Environment
- Xcode 10.3 or greater
- Swift 5.0 or greator
Demo
<img src=./Resource/gif/demo.gif width=70%>
Install
-
Install ViewGenerator from AppStore
-
Enable ViewGenerator
System Preferences→Extensions- Switch on
Xcode Source Editorcheckbox
<img src=./Resource/screenshot/setting.png width=70%>
Usage
- Input variable name
⚠Important⚠ : variable name must be included class name withoutUIas suffix. (e.g.hogeView,hogeLabel, etc.)
Please check Support View List bellow - Select variable name
Editor→ViewGenerator→Generate View Code
<img src=./Resource/screenshot/generate_view_code.png width=70%>
- Generated⚒
Recommend
I strongly recommend that you register Generate View Code Command to shortcut
Xcode Preferences→KeyBindings- Input
ViewGeneratorin Search - Register shortcut
<img src=./Resource/screenshot/shortcut.png width=70%>
Usage Example
Multiple variables
| GIF | |
|---|---|
| select | <img src=./Resource/gif/demo.gif width=70%> |
Single Variable
| GIF | |
|---|---|
| not_select | <img src=./Resource/gif/not_select.gif> |
| select | <img src=./Resource/gif/select.gif> |
Supplement
Default access modifier is private . if you change access modifier, open viewgenerator app and then select access modifier that you want to select
<img src=./Resource/screenshot/mac_app.png width=70%>
Example
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
}()
Support View List
| 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.
Contact
If you discover problem or have opinions, please let me know through Github issues💁♂️
Author
funzin
License
ViewGenerator is available under the MIT license. See the LICENSE file for more info.