Skip to content

Commit

Permalink
Display two labels in Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
thbar committed May 8, 2012
1 parent c638077 commit 1fbda77
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 01/RubyQuiz/app/app_delegate.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = QuizViewController.alloc.init
@window.rootViewController.wantsFullScreenLayout = true
@window.makeKeyAndVisible
true
end
end
25 changes: 25 additions & 0 deletions 01/RubyQuiz/app/quiz_view_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class QuizViewController < UIViewController
def viewDidLoad
@question_label = addLabel('Question', 30)
@answer_label = addLabel('Answer', 230)
# TODO - add buttons
end

def addLabel(text, y)
margin = 20
height = 30
width = view.frame.size.width - margin * 2

label = UILabel.new
label.text = text
label.frame = [[margin, y], [width, height]]
label.font = UIFont.systemFontOfSize(height)
label.textAlignment = UITextAlignmentCenter
label.textColor = UIColor.whiteColor
label.backgroundColor = UIColor.clearColor
view.addSubview(label)

label
end

end

0 comments on commit 1fbda77

Please sign in to comment.