colorWithPatternImage creates black grids in iphone 4

前端 未结 2 2102
迷失自我
迷失自我 2021-01-16 08:58

I have

UIView *topPart = [[UIView alloc] initWithFrame:CGRectMake(9, 0, 302, 318)];
topPart.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageN         


        
2条回答
  •  我在风中等你
    2021-01-16 09:27

    I was experiencing the same issue and found it was due to my png being greyscale (not RGB)

    To check if this is the case, just select the image in Xcode, show the Utilities sidebar (the one that appears from the right) and look at the Color Space.

    To fix this you can use your favourite image editor, but for photoshop do this: Open the greyscale image Select all and copy Create a new document (but this time make sure the colour space is RGB) Paste

    Hope it helps :)

提交回复
热议问题