问题
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
- Left page view controller
- Page View Controller (A little smaller than the book background view, you'll have to play with this until everything looks right)
- Book Background View (However big you want)
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