Browse files

add App.frame and UIViewController.content_frame

  • Loading branch information...
1 parent b0075c7 commit 28e874929395436bade6f41f21e1f57eaa5af046 @siuying siuying committed May 9, 2012
Showing with 16 additions and 0 deletions.
  1. +5 −0 lib/app.rb
  2. +11 −0 lib/ui_view_controller.rb
View
5 lib/app.rb
@@ -12,6 +12,11 @@ def states
def name
NSBundle.mainBundle.bundleIdentifier
end
+
+ # Return application frame
+ def frame
+ UIScreen.mainScreen.applicationFrame
+ end
# Persistence module built on top of NSUserDefaults
module Persistence
View
11 lib/ui_view_controller.rb
@@ -0,0 +1,11 @@
+class UIViewController
+ # Short hand to get the content frame
+ #
+ # Return content frame: the application frame - navigation bar frame
+ def content_frame
+ app_frame = App.frame
+ navbar_height = self.navigationController.nil? ?
+ 0 : self.navigationController.navigationBar.frame.size.height
+ CGRectMake(0, 0, app_frame.size.width, app_frame.size.height - navbar_height)
+ end
+end

0 comments on commit 28e8749

Please sign in to comment.