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





相关文章:

  • 2021-09-30
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2021-10-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
相关资源
相似解决方案