Permalink
Browse files

Display two labels in Ruby

  • Loading branch information...
thbar committed May 8, 2012
1 parent c638077 commit 1fbda77a942981d1ed1f1d2a09f6221c88ca0077
Showing with 29 additions and 0 deletions.
  1. +4 −0 01/RubyQuiz/app/app_delegate.rb
  2. +25 −0 01/RubyQuiz/app/quiz_view_controller.rb
@@ -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
@@ -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.