欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS新功能引導(dǎo)提示界面實(shí)例詳解

 更新時(shí)間:2017年04月26日 09:56:51   作者:涼城舊夢(mèng)gg  
在開(kāi)發(fā)中,現(xiàn)在很多app更新了新功能時(shí)都會(huì)給出用戶(hù)一個(gè)提示,以方便用戶(hù)更好的體驗(yàn),那么這個(gè)功能如何實(shí)現(xiàn)的呢?下面通過(guò)本文給大家分享iOS新功能引導(dǎo)提示界面實(shí)例詳解,需要的的朋友參考下吧

在開(kāi)發(fā)中,現(xiàn)在很多app更新了新功能時(shí)都會(huì)給出用戶(hù)一個(gè)提示,以方便用戶(hù)更好的體驗(yàn),那么這個(gè)功能如何實(shí)現(xiàn)的呢?

首先看下效果圖:

這里寫(xiě)圖片描述

1.首先創(chuàng)建第一個(gè)viewcontroller 在上面放上一個(gè)imageview和一個(gè)按鈕

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  UIImageView *imageview=[[UIImageView alloc]init];
  imageview.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
  imageview.image=[UIImage imageNamed:@"girl.png"];
  [self.view addSubview:imageview];
  UIButton *Btn=[[UIButton alloc]init];
  Btn.frame=CGRectMake(20, 100, 50, 50);
  Btn.backgroundColor=[UIColor blueColor];
  [Btn addTarget:self action:@selector(btnclick) forControlEvents:UIControlEventTouchUpInside];
  [imageview addSubview:Btn];
  imageview.userInteractionEnabled=YES;
}
-(void)btnclick
{
  BackViewController *backVc=[[BackViewController alloc]init];
  [self presentViewController:backVc animated:YES completion:nil];
}

2.這時(shí)候我們?cè)趧?chuàng)建一個(gè)BackViewController 設(shè)置透明即可

- (instancetype)init
{
  self = [super init];
  if (self) {
    self.view.backgroundColor=[UIColor colorWithWhite:0 alpha:0.4];
    self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    self.modalPresentationStyle = UIModalPresentationOverFullScreen;
  }
  return self;
}

這里提示一點(diǎn),很多時(shí)候我們對(duì)視圖直接設(shè)置alpha屬性的值會(huì)導(dǎo)致其子控件也變得半透明,而通常我們的需求是:背景半透明而其子控件不透明。

因此我們可以用一下方法設(shè)置透明度

//只設(shè)置黑白背景色 white后面的參數(shù)表示灰度,從0-1之間表示從黑到白的變化,alpha就是你想調(diào)整的透明度。
  blackV.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.7]; 
//設(shè)置任意顏色的背景色
blackV.backgroundColor = [UIColor colorWithRed:122/255.0 green:123/255.0 blue:234/255.0 alpha:0.7]; 
UIColor *color = [UIColor blackColor];
bgView.backgroundColor = [color colorWithAlphaComponent:0.5];

3.設(shè)置BackViewController上面的控件

- (void)viewDidLoad {
  [super viewDidLoad];
  UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
  btn.frame=CGRectMake(50, 300, 50, 50);
//  btn.backgroundColor=[UIColor blueColor];
  [self.view addSubview:btn];
  [btn setBackgroundImage:[UIImage imageNamed:@"userGuideBtnBG_unClear.png"] forState:UIControlStateNormal];
  [btn addTarget:self action:@selector(btnclick) forControlEvents:UIControlEventTouchUpInside];
  btn.backgroundColor=[UIColor clearColor];
  btn.alpha=0.75;
  UIView *view1=[[UIView alloc]init];
  view1.backgroundColor=[UIColor blackColor];
  view1.alpha=0.75;
  [self.view addSubview:view1];
  view1.frame=CGRectMake(0, 0, self.view.frame.size.width, 300);
  UIView *view2=[[UIView alloc]init];
  view2.backgroundColor=[UIColor blackColor];
  view2.alpha=0.75;
  [self.view addSubview:view2];
  view2.frame=CGRectMake(0, 300+50, self.view.frame.size.width, self.view.frame.size.height-50-300);
  UIView *view3=[[UIView alloc]init];
  view3.backgroundColor=[UIColor blackColor];
  view3.alpha=0.75;
  [self.view addSubview:view3];
  view3.frame=CGRectMake(0, 300, 50, 50);
  UIView *view4=[[UIView alloc]init];
  view4.backgroundColor=[UIColor blackColor];
  view4.alpha=0.75;
  [self.view addSubview:view4];
  view4.frame=CGRectMake(50+50, 300, self.view.frame.size.width-50-50, 50);
  UILabel *titlelabel=[[UILabel alloc]init];
  titlelabel.frame=CGRectMake(100, 350,100,50 );
  [self.view addSubview:titlelabel];
  titlelabel.text=@"這是新功能";
  titlelabel.textColor=[UIColor whiteColor];
}
-(void)btnclick
{
  [self dismissViewControllerAnimated:YES completion:nil];
}

原理很簡(jiǎn)單,我們present出來(lái)一個(gè)透明的控制器,這樣在控制器上面放上幾個(gè)深度alpha的view和一個(gè)btn,哦,還需要一個(gè)label提示文字,也可以自己再添加一些箭頭什么的,當(dāng)然這個(gè)btn時(shí)美工扣圖處理之后給你的,然后通過(guò)改變它們的frame來(lái)實(shí)現(xiàn)不同位置的提示。因?yàn)槭亲龅膁emo所以我用了frame,我建議用autolayout去定它們之間的關(guān)系,然后用transform來(lái)實(shí)現(xiàn)移動(dòng)frame,然后可以提示多個(gè)新功能。

btn摳圖之后的效果:

這里寫(xiě)圖片描述

以上所述是小編給大家介紹的iOS新功能引導(dǎo)提示界面實(shí)例詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 詳解iOS多線(xiàn)程GCD的使用

    詳解iOS多線(xiàn)程GCD的使用

    Grand Central Dispatch (GCD)是Apple開(kāi)發(fā)的一個(gè)多核編程的解決方法,本文給大家詳細(xì)介紹IOS中GCD的使用,需要的朋友參考下
    2016-03-03
  • ios利用 AFN 上傳相冊(cè)或者拍照?qǐng)D片

    ios利用 AFN 上傳相冊(cè)或者拍照?qǐng)D片

    這篇文章主要介紹了ios利用 AFN 上傳相冊(cè)或者拍照?qǐng)D片的相關(guān)資料,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2017-06-06
  • 對(duì)比分析iOS延遲執(zhí)行的4種方式

    對(duì)比分析iOS延遲執(zhí)行的4種方式

    這篇文章主要對(duì)比分析了iOS延遲執(zhí)行的4種方式,比較iOS延遲執(zhí)行方式的特點(diǎn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • iOS的XMPPFramework簡(jiǎn)單介紹(實(shí)現(xiàn)及時(shí)通信)

    iOS的XMPPFramework簡(jiǎn)單介紹(實(shí)現(xiàn)及時(shí)通信)

    這篇文章主要介紹了iOS的XMPPFramework簡(jiǎn)單介紹(實(shí)現(xiàn)及時(shí)通信),實(shí)現(xiàn)了基于XMPP協(xié)議通信的開(kāi)發(fā),有需要的朋友可以了解一下。
    2016-11-11
  • iOS使用xib手動(dòng)實(shí)現(xiàn)動(dòng)畫(huà)效果的方法

    iOS使用xib手動(dòng)實(shí)現(xiàn)動(dòng)畫(huà)效果的方法

    下面小編就為大家分享一篇iOS使用xib手動(dòng)實(shí)現(xiàn)動(dòng)畫(huà)效果的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-01-01
  • iOS如何定義名為任意的變量詳解

    iOS如何定義名為任意的變量詳解

    這篇文章主要給大家介紹了關(guān)于iOS如何定義名為任意的變量的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)各位iOS開(kāi)發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-05-05
  • iOS輸出手機(jī)系統(tǒng)版本號(hào)

    iOS輸出手機(jī)系統(tǒng)版本號(hào)

    這篇文章主要介紹了iOS輸出手機(jī)系統(tǒng)版本號(hào)的相關(guān)資料,需要的朋友可以參考下
    2017-07-07
  • iOS本地推送簡(jiǎn)單實(shí)現(xiàn)代碼

    iOS本地推送簡(jiǎn)單實(shí)現(xiàn)代碼

    這篇文章主要為大家詳細(xì)介紹了iOS本地推送簡(jiǎn)單實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • iOS自定義UIDatePicker日期選擇器視圖

    iOS自定義UIDatePicker日期選擇器視圖

    這篇文章主要為大家詳細(xì)介紹了iOS自定義UIDatePicker日期選擇器視圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-04-04
  • iOS如何巧妙解決NSTimer的循環(huán)引用詳解

    iOS如何巧妙解決NSTimer的循環(huán)引用詳解

    這篇文章主要給大家介紹了關(guān)于iOS如何巧妙解決NSTimer的循環(huán)引用的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-03-03

最新評(píng)論