Correct way to load a background image for a Page Based application in iOS 5?

左心房为你撑大大i 提交于 2019-12-20 04:54:09

问题


I'm working on an iBooks type of app for iOS 5 and have everything working except for the background image. Specifically in landscape mode.

Up to this point I've been using:

UIImageView *background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"book.png"]];

[self.view addSubview:background];
[self.view sendSubviewToBack:background];

If I do this on the RootViewController, the spine obviously doesn't show through the page view controller's view and if I use this inside the page view controller class, it removes the ability to use CGRectInset to specify where the pagecurl should begin.

I'm sure this is probably something pretty basic, but I've looked through every book that I have as well as Google, and I don't see this covered anywhere. Any help would be appreciated.

Thanks


回答1:


You will need to use a background image for your book and then use a right page image for the right side and a left side image for the left side. These will need to align and match up with the full book background image. You can use a UIImageView for all three. Keep in mind that the left and right page images will need to be perfectly square (except for the spine) with no transparent area, otherwise you get a weird shadowing effect. Also make sure all background colors are set to clear.

So you will have this hierarchy:

  • Root View (full screen bounds)
    • Book Background View (However big you want)
      • Page View Controller (A little smaller than the book background view, you'll have to play with this until everything looks right)
        • Left page view controller
          • Image of left page and whatever else goes on the page
        • Right page view controller
          • Image of right page and whatever else goes on the page

I hope this makes sense.



来源:https://stackoverflow.com/questions/9979331/correct-way-to-load-a-background-image-for-a-page-based-application-in-ios-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!