iOS 5.1 : -[UIColor colorWithPatternImage:] background color draws solid black

后端 未结 2 1390
既然无缘
既然无缘 2020-12-29 15:00

While testing my application in today\'s release of iOS 5.1 GM, I noticed that some of my views are drawing solid black rather than their patterned background color. The ex

2条回答
  •  囚心锁ツ
    2020-12-29 15:31

    I was having this problem with iOS 5.1 on an iPad where I was using colorWithPatternImage on a UIScrollView like this:

    scrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"YOURIMAGE.jpg"]];
    

    This works in iOS 6 (e.g. iPad2 and beyond), however, on an original iPad, where you can only update your iOS to 5.1.1, this will show up white or another solid color you defined somewhere. The fix is to use a slightly less attractive method where you set the backgroundView of the scrollView like this:

    scrollView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"YOURIMAGE.png"]];
    

    I've tested this in iOS 6 and iOS 5.1, so it should also apply to the iPhone if you're running into problems there.

提交回复
热议问题