Permalink
Browse files

Add buttons

  • Loading branch information...
1 parent 1fbda77 commit 860f7c92e1dee63f23cab72ffc8f4f5b5a213033 @thbar committed May 8, 2012
Showing with 23 additions and 3 deletions.
  1. +23 −3 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)

0 comments on commit 860f7c9

Please sign in to comment.