国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > iOS > 正文

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

2019-10-21 18:46:47
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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

首先看下效果圖:

ios,新功能引導(dǎo)提示

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摳圖之后的效果:

ios,新功能引導(dǎo)提示

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


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到IOS開(kāi)發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 苗栗县| 霸州市| 石城县| 山阳县| 奈曼旗| 伽师县| 合作市| 兖州市| 东乌| 揭西县| 乃东县| 榆林市| 囊谦县| 贵定县| 米脂县| 泰兴市| 高密市| 连南| 辽源市| 含山县| 彭泽县| 偏关县| 浠水县| 桓仁| 温宿县| 河东区| 上杭县| 南安市| 邻水| 精河县| 石渠县| 翁源县| 荆门市| 柳河县| 南充市| 平山县| 虹口区| 樟树市| 安阳市| 彭泽县| 襄垣县|