iOS开发 - 三方库实现聚光引导效果与触摸跟踪动效

效果展示

这里写图片描述

三方资源

  • EMHint:实现聚光灯效果;

  • COSTouchVisualizerWindow:实现触摸跟踪动效;

注意:三方资源直接附在Demo下载中,欢迎下载。

关键代码片段

  • EMHint
#pragma mark - 加载闪光灯

- (void)addSpotlight {

    CGFloat width = WITH/4;
    CGFloat centextY = HEIGHT - 50/2;

    // 创建闪光灯
    XSportLight *sportLight = [[XSportLight alloc] init];
    // 设置依次显示的文本
    sportLight.messageArray = @[@"这是一个主页界面",
                                @"这是一个消息界面",
                                @"这是一个音乐界面",
                                @"这是一个动态界面",
                                @"动画引导结束"];
    // 设置依次显示的位置
    // 注意:CGRectMake 中,x、y值设置的 聚光灯 中心点在屏幕的位置。
    sportLight.rectArray = @[[NSValue valueWithCGRect:CGRectMake(width/2, centextY, 50, 50)],
                             [NSValue valueWithCGRect:CGRectMake(width+width/2, centextY, 50, 50)],
                             [NSValue valueWithCGRect:CGRectMake(2*width+width/2, centextY, 50, 50)],
                             [NSValue valueWithCGRect:CGRectMake(3*width+width/2, centextY, 50, 50)],
                             [NSValue valueWithCGRect:CGRectMake(0, 0, 0, 0)],];
    sportLight.delegate = self;
    [self presentViewController:sportLight animated:false completion:nil];
}
  • COSTouchVisualizerWindow

AppDelegate.h

#import <UIKit/UIKit.h>
#import "COSTouchVisualizerWindow.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) COSTouchVisualizerWindow *window;

@end

AppDelegate.m

#import "AppDelegate.h"
#import "TabBarViewController.h"

@interface AppDelegate ()


@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

    _window = [[COSTouchVisualizerWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

    _window.backgroundColor = [UIColor blackColor];

    _window.rootViewController = [[TabBarViewController alloc] init];

    [_window makeKeyAndVisible];

    return YES;
}


@end

Demo下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值