Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add buttons

  • Loading branch information...
commit 860f7c92e1dee63f23cab72ffc8f4f5b5a213033 1 parent 1fbda77
@thbar authored
Showing with 23 additions and 3 deletions.
  1. +23 −3 01/RubyQuiz/app/quiz_view_controller.rb
View
26 01/RubyQuiz/app/quiz_view_controller.rb
@@ -1,8 +1,28 @@
class QuizViewController < UIViewController
def viewDidLoad
- @question_label = addLabel('Question', 30)
- @answer_label = addLabel('Answer', 230)
- # TODO - add buttons
+ pad = view.bounds.size.height / (1 + 2 + 1 + 2 + 1)
+ y = 0
+
+ @question_label = addLabel('Question', y += pad)
+ @question_button = addButton('Show Question', y += pad)
+
+ y += pad
+
+ @answer_label = addLabel('Answer', y += pad)
+ @answer_button = addButton('Show Answer', y += pad)
+ end
+
+ def addButton(text, y)
+ margin = 20
+ height = 30
+ width = view.frame.size.width - margin * 2
+
+ button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
+ button.setTitle(text, forState: UIControlStateNormal)
+ button.frame = [[margin, y], [width, height]]
+ view.addSubview(button)
+
+ button
end
def addLabel(text, y)
Please sign in to comment.
Something went wrong with that request. Please try again.