Reputation: 6873
I have an iPhone app where I have a view and following hierarchy.
View
ImageView
ScrollView
OtherItems
I have ImageView background set to an image and ScrollView color to clearColor but still the background is white in simulator and iphone both. Why is that so? Although I can see the background in the IB.
Upvotes: 0
Views: 785
Reputation: 831
Maybe your "Other Items" have the background set to whiteColor ... Or you can set the backgroundColor of the scrollView to the image in code.
scrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];
Also, if you have a large image or your scrollView remains in memory a long time, you shouldn't use the imageNamed: method because it caches the image and drains memory; you should use imageWithContentsOfFile: instead.
scroll.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]]];
Upvotes: 1
Reputation: 48398
Step 1: Check that the image name is exactly correct (case sensitive) and that the image file has been added to the project.
Step 2: Set the imageView image to a color and see if anything changes. If yes, double check step 1. If no, post some code.
Upvotes: 1