Is it possible to make just the background开发者_JAVA技巧 semi transparent? If I change the alpha it changes the title and the boarder. I can change the titleLabel.alpha property but it won't go above the buttons Alpha, only below it.
I know I can make a custom one but thought there would be an easier way
Render a blank button with something like this:
UIGraphicsBeginImageContextWithOptions(size,0,0);
[button.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
From there, it's not hard to halve the alpha (fill it with a 50% opaque rect in "DestOver" blend mode before pulling the image out?). Then set it as the background for a custom button.
Icky. Oh well.
Alternatively, you can modify the view in the view hierarchy directly; not recommended, since it tends to break across OS releases.
精彩评论