我有一个透明的UIToolbar,通过设置半透明真实并更改背景alpha。如何让工具栏按钮不透明?我尝试添加这样的非透明图像:
CGRect rect = CGRectMake(0, 0, ([AppDelegate isInIPad])?768:320, 20);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.filterButton setBackgroundImage:image forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
答案 0 :(得分:0)
试试这个:
[yourToolbar setBackgroundImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
[yourToolbar setBackgroundColor:[UIColor clearColor]];
[yourToolbar setShadowImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny];