【问题标题】:Transparent UIToolBar with Non-transparent UIBarButtonItem带有非透明 UIBarButtonItem 的透明 UIToolBar
【发布时间】:2014-03-31 02:23:24
【问题描述】:

通过设置半透明 true 并更改背景 alpha,我有一个透明的 UIToolbar。如何使工具栏按钮不透明?我尝试添加这样的非透明图像:

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];

【问题讨论】:

    标签: ios7 uibarbuttonitem uitoolbar


    【解决方案1】:

    试试这个:

    [yourToolbar setBackgroundImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];    
    [yourToolbar setBackgroundColor:[UIColor clearColor]];    
    [yourToolbar setShadowImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny];
    

    【讨论】:

      猜你喜欢
      • 2011-09-09
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 2014-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多