Objective-C實(shí)現(xiàn)自定義的半透明導(dǎo)航
更新時(shí)間:2016年05月16日 16:25:49 作者:隨心_而動
這篇文章主要為大家詳細(xì)介紹了Objective-C實(shí)現(xiàn)自定義的半透明導(dǎo)航的相關(guān)資料,需要的朋友可以參考下
本文實(shí)例為大家分享了Objective-C半透明導(dǎo)航的具體實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
#define kScreenWidth [[UIScreen mainScreen] bounds].size.width
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
#import "RSwenNav.h"
@implementation RSwenNav
{
UIVisualEffectView *effectview;
}
-(instancetype)initWithFrame:(CGRect)frame{
self=[super initWithFrame:frame];
if (self) {
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
effectview.frame=frame;
[self addSubview:effectview];
[self addSubviews];
}
return self;
}
//添加導(dǎo)航子視圖
-(void)addSubviews{
[self addSubview:self.backBtn];
[self addSubview:self.titleLabel];
[self addSubview:self.rightBtn];
}
-(UIButton *)backBtn{
UIButton * btn=[UIButton buttonWithType:UIButtonTypeCustom];
btn.frame=CGRectMake(20, 20, 60, 44);
[btn setTitle:@"返回" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(RSwenNavback) forControlEvents:UIControlEventTouchUpInside];
return btn;
}
-(UILabel *)titleLabel{
UILabel * lable=[[UILabel alloc]init];
lable.font=[UIFont systemFontOfSize:17];
lable.textAlignment=NSTextAlignmentCenter;
lable.frame=CGRectMake(100, 20, kScreenWidth-200, 44);
lable.text=@"我的主頁";
return lable;
}
-(UIButton *)rightBtn{
UIButton * btn=[UIButton buttonWithType:UIButtonTypeCustom];
btn.frame=CGRectMake([UIScreen mainScreen].bounds.size.width-100, 20, 80, 44);
[btn setTitle:@"保存" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(rightBtnClicked) forControlEvents:UIControlEventTouchUpInside];
return btn;
}
#pragma 事件處理部分
//返回上個界面
-(void)RSwenNavback{
//獲取UIView的上層UIViewController
id object = [self nextResponder];
while (![object isKindOfClass:[UIViewController class]] &&
object != nil) {
object = [object nextResponder];
}
UIViewController *uc=(UIViewController*)object;
[uc.navigationController popViewControllerAnimated:YES];
}
//右側(cè)按鈕被點(diǎn)擊
-(void)rightBtnClicked{
if ([_delegate respondsToSelector:@selector(RSwenNavrightBtnClicked)]) {
[_delegate RSwenNavrightBtnClicked];
}
}
@end
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。
您可能感興趣的文章:
- 如何使用jQuery技術(shù)開發(fā)ios風(fēng)格的頁面導(dǎo)航菜單
- iOS開發(fā)中導(dǎo)航控制器的基本使用教程
- 詳解iOS開發(fā)中使用storyboard創(chuàng)建導(dǎo)航控制器的方法
- IOS仿今日頭條滑動導(dǎo)航欄
- iOS應(yīng)用開發(fā)中導(dǎo)航欄按鈕UIBarButtonItem的添加教程
- 深入學(xué)習(xí)iOS7自定義導(dǎo)航轉(zhuǎn)場動畫
- iOS App開發(fā)中導(dǎo)航欄的創(chuàng)建及基本屬性設(shè)置教程
- iOS實(shí)現(xiàn)頂部標(biāo)簽式導(dǎo)航欄及下拉分類菜單
- IOS百度地圖導(dǎo)航開發(fā)功能實(shí)現(xiàn)簡述
- 詳解iOS應(yīng)用中自定義UIBarButtonItem導(dǎo)航按鈕的創(chuàng)建方法
相關(guān)文章
iOS開發(fā)之(APNS)遠(yuǎn)程推送實(shí)現(xiàn)代碼 附證書與真機(jī)調(diào)試
這篇文章主要為大家詳細(xì)介紹了iOS開發(fā)之(APNS)遠(yuǎn)程推送實(shí)現(xiàn)代碼,附證書與真機(jī)調(diào)試,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09
實(shí)例講解iOS應(yīng)用UI開發(fā)之基礎(chǔ)動畫的創(chuàng)建
這篇文章主要介紹了iOS應(yīng)用UI開發(fā)之基礎(chǔ)動畫的創(chuàng)建,以關(guān)鍵幀動畫作為重要知識點(diǎn)進(jìn)行講解,需要的朋友可以參考下2015-11-11
iOS開發(fā)中使用Quartz2D繪圖及自定義UIImageView控件
這篇文章主要介紹了iOS開發(fā)中使用Quartz2D繪圖及自定義UIImageView控件的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-11-11
IOS應(yīng)用內(nèi)支付返回新舊Receipt適配的方法
本篇文章主要介紹了IOS應(yīng)用內(nèi)支付返回新舊Receipt適配的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12

