Transparent UIToolbar

前端 未结 7 1316
萌比男神i
萌比男神i 2021-02-14 19:42

I wrote the following code to make my toolbar transparent.

[mtoolbar setBackgroundColor:[UIColor clearColor]];

How do I make UIToolbar

7条回答
  •  南笙
    南笙 (楼主)
    2021-02-14 20:03

    This worked for me for iOS 6 and 7:

    UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 0.0);
    UIImage *blank = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    [self.toolBar setBackgroundImage:blank forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
    

提交回复
热议问题