This example shares the specific implementation code of Objective-C translucent navigation for your reference. The specific content is as follows
#define kScreenWidth [[UIScreen mainScreen] bounds]. #define kScreenHeight [[UIScreen mainScreen] bounds]. #import "" @implementation RSwenNav { UIVisualEffectView *effectview; } -(instancetype)initWithFrame:(CGRect)frame{ self=[super initWithFrame:frame]; if (self) { UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; effectview = [[UIVisualEffectView alloc] initWithEffect:blur]; =frame; [self addSubview:effectview]; [self addSubviews]; } return self; } //Add navigation subview-(void)addSubviews{ [self addSubview:]; [self addSubview:]; [self addSubview:]; } -(UIButton *)backBtn{ UIButton * btn=[UIButton buttonWithType:UIButtonTypeCustom]; =CGRectMake(20, 20, 60, 44); [btn setTitle:@"return" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(RSwenNavback) forControlEvents:UIControlEventTouchUpInside]; return btn; } -(UILabel *)titleLabel{ UILabel * lable=[[UILabel alloc]init]; =[UIFont systemFontOfSize:17]; =NSTextAlignmentCenter; =CGRectMake(100, 20, kScreenWidth-200, 44); =@"My Homepage"; return lable; } -(UIButton *)rightBtn{ UIButton * btn=[UIButton buttonWithType:UIButtonTypeCustom]; =CGRectMake([UIScreen mainScreen].-100, 20, 80, 44); [btn setTitle:@"save" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(rightBtnClicked) forControlEvents:UIControlEventTouchUpInside]; return btn; } #pragma event handling section //Return to the previous interface-(void)RSwenNavback{ //Get the upper UIViewController of the UIView id object = [self nextResponder]; while (![object isKindOfClass:[UIViewController class]] && object != nil) { object = [object nextResponder]; } UIViewController *uc=(UIViewController*)object; [ popViewControllerAnimated:YES]; } //The button on the right is clicked-(void)rightBtnClicked{ if ([_delegate respondsToSelector:@selector(RSwenNavrightBtnClicked)]) { [_delegate RSwenNavrightBtnClicked]; } } @end
The above is all about this article, I hope it will be helpful to everyone's learning.