Button background and gradient change since iOS6

别等时光非礼了梦想. 提交于 2019-12-03 14:39:44

This is a really strange problem in ios6 ,I faced the same problem when setting gradient like you typically would:

[myButton.layer insertSublayer:gradient atIndex:0];

so I tried changing the bottom line to this which worked perfectly fine in iOS 6 and also in lower versions of IOS

[myButton.layer insertSublayer:gradient below:myButton.titleLabel.layer];

hope this will help

Edelweiss

As you can see in my comment the problem came from the class UIGroupTableViewCellBackground, I just hide it. I think this is not a "clean" solution, if you have a better one İ'll be glad to hear about it :-)

Here is the code :

for(UIView* subView in btnCountry.subviews)
    if([subView isKindOfClass:NSClassFromString(@"UIGroupTableViewCellBackground")])
        [subView setHidden:YES];

Inserting the layer at index position 1 works for me.

Probably the best solution is to check the iOS version and depending on that, insert at index 0 or 1.

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