最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

在開(kāi)發(fā)中,現(xiàn)在很多app更新了新功能時(shí)都會(huì)給出用戶一個(gè)提示,以方便用戶更好的體驗(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)文章

最新評(píng)論

宝兴县| 大方县| 泰州市| 通许县| 红原县| 寿光市| 久治县| 通山县| 福清市| 吉安县| 康马县| 梅河口市| 航空| 余庆县| 鹿邑县| 怀柔区| 成武县| 从江县| 宜川县| 大姚县| 沁源县| 神木县| 巨野县| 青冈县| 宣武区| 嘉祥县| 加查县| 炉霍县| 漳浦县| 惠来县| 陵水| 胶州市| 望奎县| 扎鲁特旗| 东安县| 秦皇岛市| 武鸣县| 齐河县| 吉木萨尔县| 兴宁市| 海口市|