效果展示
三方资源
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