TranslucentToolbar.h文件
#import <UIKit/UIKit.h>
@interface TranslucentToolbar :
UIToolbar
@end
TranslucentToolbar.m文件
#import "TranslucentToolbar.h"
@implementation TranslucentToolbar
- (id)initWithFrame:(CGRect)aRect {
if ((self = [super
initWithFrame:aRect])) {
self.opaque =
NO;
self.backgroundColor = [UIColor
colorWithRed:34.0/255.0
green:39.0/255.0
blue:42.0/255.0
alpha:0.8];
self.clearsContextBeforeDrawing =
YES;
}
return
self;
}
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
@end
在需要创建的地方使用子类化的UIToolbar:
_bottomBar =[[TranslucentToolbar
alloc] initWithFrame:CGRectMake(0, height-botH, width, botH)];
创建透明的UIToolbar
时间: 2024-11-07 22:23:31