Skip to content

Instantly share code, notes, and snippets.

@jonathontoon
Created May 5, 2017 21:38
Show Gist options
  • Save jonathontoon/1ba483045679f43d091118394c91e4ae to your computer and use it in GitHub Desktop.
Save jonathontoon/1ba483045679f43d091118394c91e4ae to your computer and use it in GitHub Desktop.
class MyViewController {
let titleOfGoal: String;
let titleLabel: UILabel;
let goalLabels: [UILabel];
let goalObjects: Array;
init(t: String) {
super.init();
titleOfGoal = t;
goalObjects = [
{
"title": "Do thing 1",
},{
"title": "Do thing 2",
},{
"title": "Do thing 3",
},
];
}
viewDidLoad() {
super.viewDidLoad();
titleLabel = UILabel(string: titleOfGoal);
// Style, do stuff with autolayout, or size frame...
addSubview(titleLabel);
for goal in goalObjects {
let goalLabel = UILabel(string: goal.title);
// Style, do stuff with autolayout, or size frame...
let tapGesture = UITapGestureRecognizer();
// Config your tap gesture...
goalLabels.addGestureRecognizer(tapGesture);
goalLabels.append(goalLabel);
addSubview(goalLabel);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment