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

首頁 > 系統 > iOS > 正文

iOS開發添加新手引導效果

2020-07-26 01:28:41
字體:
來源:轉載
供稿:網友

往往項目中經常出現此類需求

用戶通過點擊引導按鈕可響應頁面附帶按鈕的點擊事件。

//// gzhGuideView.h// GuideView//// Created by 郭志賀 on 2020/5/29.// Copyright © 2020 郭志賀. All rights reserved.//#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGIN@interface gzhGuideView : UIView-(void)showGuide:(UIView*)view;//顯示引導-(void)dismissGuide;//移除@endNS_ASSUME_NONNULL_END
//// gzhGuideView.m// GuideView//// Created by 郭志賀 on 2020/5/29.// Copyright © 2020 郭志賀. All rights reserved.//#import "gzhGuideView.h"@implementation gzhGuideView-(instancetype)initWithFrame:(CGRect)frame{  if (self = [super initWithFrame:frame]) {    self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];    //主要代碼 添加路徑    UIBezierPath *path = [UIBezierPath bezierPathWithRect:frame];    // 這里添加第二個路徑 需要扣除的部分    [path appendPath:[[UIBezierPath bezierPathWithRoundedRect:CGRectMake(100, 100, 150, 40) cornerRadius:5] bezierPathByReversingPath]];    //渲染    CAShapeLayer *shapeLayer = [CAShapeLayer layer];    shapeLayer.path = path.CGPath;    [self.layer setMask:shapeLayer];    //根據需求添加按鈕 實現點擊事件    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];    button.frame = CGRectMake(100, 100, 150, 40);    [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];    button.layer.cornerRadius = 5.0f;    button.layer.masksToBounds = YES;    [self addSubview:button];  }  return self;}-(void)showGuide:(UIView *)view{//添加  [view.window addSubview:self];  [view.window bringSubviewToFront:self];  self.alpha = 1;}-(void)dismissGuide{//移除  [self removeFromSuperview];}-(void)buttonClick{  [self dismissGuide];  NSLog(@"引導狀態可點擊");}@end

相應頁面直接添加

gzhGuideView * guide = [[gzhGuideView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];dispatch_async(dispatch_get_main_queue(), ^{[guide showGuide: self .view]; });

可根據不同需求進行不同的布局,核心代碼就是添加路徑

總結

到此這篇關于iOS開發添加新手引導的實例代碼的文章就介紹到這了,更多相關ios新手引導內容請搜索武林網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持武林網!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吉林省| 东丽区| 平罗县| 株洲市| 巴林左旗| 嘉义市| 阿尔山市| 崇仁县| 疏附县| 贡觉县| 佛冈县| 宜兰县| 潞城市| 五常市| 阜阳市| 行唐县| 通道| 河间市| 中宁县| 江山市| 绥阳县| 静安区| 修文县| 台北县| 清水河县| 乌苏市| 晋中市| 新丰县| 曲松县| 水城县| 双峰县| 广东省| 丰台区| 竹溪县| 寿光市| 桃园市| 江孜县| 雷波县| 巧家县| 洪雅县| 新竹市|