iOS开发添加新手引导效果开发添加新手引导效果
主要介绍了iOS开发添加新手引导效果,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一
定的参考借鉴价值,需要的朋友可以参考下
往往项目中经常出现此类需求
用户通过点击引导按钮可响应页面附带按钮的点击事件。
//
// 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;//移除
@end
NS_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]];