最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

IOS實現簽到特效(散花效果)的實例代碼

 更新時間:2018年05月14日 17:33:23   作者:GuiGen_L  
這篇文章主要介紹了IOS實現簽到特效(散花效果)的實例代碼,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

本文講述了IOS實現簽到特效(散花效果)實例代碼。分享給大家供大家參考,具體如下:

散花特效

#import <Foundation/Foundation.h>
/// 領取獎勵成功
@interface RewardSuccess : NSObject
/**
 * 成功動畫
 */
+ (void)show;

@end
#import "RewardSuccess.h"
#import "RewardSuccessWindow.h"
#define EmitterColor_Red [UIColor colorWithRed:255/255.0 green:0 blue:139/255.0 alpha:1]
#define EmitterColor_Yellow [UIColor colorWithRed:251/255.0 green:197/255.0 blue:13/255.0 alpha:1]
#define EmitterColor_Blue [UIColor colorWithRed:50/255.0 green:170/255.0 blue:207/255.0 alpha:1]
@implementation RewardSuccess
+ (void)show
{
 UIWindow *window = [UIApplication sharedApplication].keyWindow;
 UIView *backgroundView = [[UIView alloc] initWithFrame:window.bounds];
 backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8];
 [window addSubview:backgroundView];
 RewardSuccessWindow *successWindow = [[RewardSuccessWindow alloc] initWithFrame:CGRectZero];
 [backgroundView addSubview:successWindow];
 //縮放
 successWindow.transform=CGAffineTransformMakeScale(0.01f, 0.01f);
 successWindow.alpha = 0;
 [UIView animateWithDuration:0.4 animations:^{
 successWindow.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
 successWindow.alpha = 1;
 }];
 //3s 消失
 double delayInSeconds = 3;
 dispatch_time_t delayInNanoSeconds = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
 dispatch_after(delayInNanoSeconds, dispatch_get_main_queue(), ^(void){
 [UIView animateWithDuration:0.4 animations:^{
  successWindow.transform = CGAffineTransformMakeScale(.3f, .3f);
  successWindow.alpha = 0;
 }completion:^(BOOL finished) {
  [backgroundView removeFromSuperview];
 }];
 });
 //開始粒子效果
 CAEmitterLayer *emitterLayer = addEmitterLayer(backgroundView,successWindow);
 startAnimate(emitterLayer);
}
CAEmitterLayer *addEmitterLayer(UIView *view,UIView *window)
{
 //色塊粒子
 CAEmitterCell *subCell1 = subCell(imageWithColor(EmitterColor_Red));
 subCell1.name = @"red";
 CAEmitterCell *subCell2 = subCell(imageWithColor(EmitterColor_Yellow));
 subCell2.name = @"yellow";
 CAEmitterCell *subCell3 = subCell(imageWithColor(EmitterColor_Blue));
 subCell3.name = @"blue";
 CAEmitterCell *subCell4 = subCell([UIImage imageNamed:@"success_star"]);
 subCell4.name = @"star";
 CAEmitterLayer *emitterLayer = [CAEmitterLayer layer];
 emitterLayer.emitterPosition = window.center;
 emitterLayer.emitterPosition = window.center;
 emitterLayer.emitterSize = window.bounds.size;
 emitterLayer.emitterMode = kCAEmitterLayerOutline;
 emitterLayer.emitterShape = kCAEmitterLayerRectangle;
 emitterLayer.renderMode = kCAEmitterLayerOldestFirst;
 emitterLayer.emitterCells = @[subCell1,subCell2,subCell3,subCell4];
 [view.layer addSublayer:emitterLayer];
 return emitterLayer;

}
void startAnimate(CAEmitterLayer *emitterLayer)
{
 CABasicAnimation *redBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.red.birthRate"];
 redBurst.fromValue = [NSNumber numberWithFloat:30];
 redBurst.toValue  = [NSNumber numberWithFloat: 0.0];
 redBurst.duration = 0.5;
 redBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
 CABasicAnimation *yellowBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.yellow.birthRate"];
 yellowBurst.fromValue = [NSNumber numberWithFloat:30];
 yellowBurst.toValue  = [NSNumber numberWithFloat: 0.0];
 yellowBurst.duration = 0.5;
 yellowBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
 CABasicAnimation *blueBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.blue.birthRate"];
 blueBurst.fromValue = [NSNumber numberWithFloat:30];
 blueBurst.toValue  = [NSNumber numberWithFloat: 0.0];
 blueBurst.duration = 0.5;
 blueBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
 CABasicAnimation *starBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.star.birthRate"];
 starBurst.fromValue = [NSNumber numberWithFloat:30];
 starBurst.toValue  = [NSNumber numberWithFloat: 0.0];
 starBurst.duration = 0.5;
 starBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
 CAAnimationGroup *group = [CAAnimationGroup animation];
 group.animations = @[redBurst,yellowBurst,blueBurst,starBurst];
 [emitterLayer addAnimation:group forKey:@"heartsBurst"];
}
CAEmitterCell *subCell(UIImage *image)
{
 CAEmitterCell * cell = [CAEmitterCell emitterCell];
 cell.name = @"heart";
 cell.contents = (__bridge id _Nullable)image.CGImage;
 // 縮放比例
 cell.scale = 0.6;
 cell.scaleRange = 0.6;
 // 每秒產生的數量
 // cell.birthRate = 40;
 cell.lifetime = 20;
 // 每秒變透明的速度
 // snowCell.alphaSpeed = -0.7;
 // snowCell.redSpeed = 0.1;
 // 秒速
 cell.velocity = 200;
 cell.velocityRange = 200;
 cell.yAcceleration = 9.8;
 cell.xAcceleration = 0;
 //掉落的角度范圍
 cell.emissionRange = M_PI;
 cell.scaleSpeed = -0.05;
 //// cell.alphaSpeed = -0.3;
 cell.spin  = 2 * M_PI;
 cell.spinRange = 2 * M_PI;
 return cell;
}
UIImage *imageWithColor(UIColor *color)
{
 CGRect rect = CGRectMake(0, 0, 13, 17);
 UIGraphicsBeginImageContext(rect.size);
 CGContextRef context = UIGraphicsGetCurrentContext();
 CGContextSetFillColorWithColor(context, [color CGColor]);
 CGContextFillRect(context, rect);
 UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 return image;
}
@end

領取獎勵成功提示框

#import <UIKit/UIKit.h>
/// 領取獎勵成功提示框
@interface RewardSuccessWindow : UIView
@end
#import "RewardSuccessWindow.h"
static CGFloat SuccessWindow_width = 270;
static CGFloat SuccessWindow_hight = 170;
@implementation RewardSuccessWindow
 (instancetype)initWithFrame:(CGRect)frame
{
 CGSize screenSize = [UIScreen mainScreen].bounds.size;
 self = [super initWithFrame:CGRectMake((screenSize.width - SuccessWindow_width)/2.0 , (screenSize.height - SuccessWindow_hight)/2.0, SuccessWindow_width, SuccessWindow_hight)];
 if (self)
 {
 [self configSubViews];
 }
 return self;
}
- (void)configSubViews
{
 self.backgroundColor = [UIColor whiteColor];
 self.layer.cornerRadius = 10;
 self.layer.masksToBounds = YES;
 UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 45, SuccessWindow_width, 22)];
 titleLabel.text = @"恭喜您,領取成功!";
 titleLabel.font = [UIFont systemFontOfSize:19.0];
 titleLabel.textAlignment = NSTextAlignmentCenter;
 [self addSubview:titleLabel];
 UILabel *expLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 75, SuccessWindow_width, 43)];
 expLabel.font = [UIFont systemFontOfSize:15];
 expLabel.textAlignment = NSTextAlignmentCenter;
 [self addSubview:expLabel];
 NSString *string = @"獲得經驗:+6";
 NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
 [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, string.length)];
 [attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"MarkerFelt-Thin" size:35] range:NSMakeRange(5,2)];
 NSShadow *shadow =[[NSShadow alloc] init];
 shadow.shadowOffset = CGSizeMake(1, 3);
 [attributedString addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(5,2)];
 [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(5,2)];
 expLabel.attributedText = attributedString;
 UILabel *bottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 135, SuccessWindow_width, 22)];
 bottomLabel.text = @"可以在我的->我的獎勵中查看獲得獎勵";
 bottomLabel.font = [UIFont systemFontOfSize:13.0];
 bottomLabel.textAlignment = NSTextAlignmentCenter;
 bottomLabel.textColor = [UIColor colorWithRed:177/255.0 green:177/255.0 blue:177/255.0 alpha:1];
 [self addSubview:bottomLabel];
}

@end

相關文章

  • iOS App中調用iPhone各種感應器的方法總結

    iOS App中調用iPhone各種感應器的方法總結

    Xcode環(huán)境中包含CoreMotion框架,能夠幫助我們調用硬件設備的加速度傳感器和陀螺儀等感應器,下面比較詳細地整理了iOS App中調用iPhone各種感應器的方法總結,需要的朋友可以參考下:
    2016-07-07
  • iOS CoreAnimation 圖層幾何學

    iOS CoreAnimation 圖層幾何學

    本文主要介紹了iOS CoreAnimation圖層幾何學,圖層幾何所講主要是有關圖層的位置,尺寸等幾何類屬性。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-03-03
  • iOS11新特性之在你的APP中使用LargeTitle

    iOS11新特性之在你的APP中使用LargeTitle

    本篇文章主要介紹了iOS11新特性之在你的APP中使用LargeTitle,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-12-12
  • iOS開發(fā)之離線地圖核心代碼

    iOS開發(fā)之離線地圖核心代碼

    本文給大家分享ios開發(fā)之離線地圖核心代碼,代碼簡單易懂,非常實用,有需要的朋友參考下
    2016-04-04
  • Objective-C Json 實例詳解

    Objective-C Json 實例詳解

    這篇文章主要介紹了 Objective-C Json 實例詳解的相關資料,希望通過本文能幫助到大家,讓大家掌握Object-C Json的使用,需要的朋友可以參考下
    2017-10-10
  • iOS Swift控制器轉場動畫示例代碼

    iOS Swift控制器轉場動畫示例代碼

    這篇文章主要給大家介紹了關于iOS Swift控制器轉場動畫的相關資料,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者們具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2018-01-01
  • iOS 9 更新之Safari廣告攔截器(Content Blocker)開發(fā)教程

    iOS 9 更新之Safari廣告攔截器(Content Blocker)開發(fā)教程

    這篇文章主要介紹了iOS 9 更新之Safari廣告攔截器(Content Blocker)開發(fā)教程的相關資料,需要的朋友可以參考下
    2015-08-08
  • iOS開發(fā)教程之UIView和UIViewController的生命周期詳解

    iOS開發(fā)教程之UIView和UIViewController的生命周期詳解

    UIViewController是IOS程序中的一個重要組成部分,下面這篇文章主要給大家介紹了關于iOS開發(fā)教程之UIView和UIViewController的生命周期的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2018-04-04
  • iOS開發(fā)實現音頻播放功能

    iOS開發(fā)實現音頻播放功能

    本文給大家分享的是在IOS開發(fā)過程中實現音頻播放的功能,講解的十分細致,有需要的小伙伴可以參考下
    2016-03-03
  • UIImage加載圖片Images.xcassets加載方法的影響

    UIImage加載圖片Images.xcassets加載方法的影響

    這篇文章主要介紹了UIImage加載圖片Images.xcassets加載方法的影響的相關資料,需要的朋友可以參考下
    2016-12-12

最新評論

台山市| 石林| 通化县| 精河县| 绥中县| 康定县| 石狮市| 临澧县| 河西区| 理塘县| 沙雅县| 湄潭县| 和硕县| 军事| 华亭县| 张家港市| 建阳市| 长海县| 吴川市| 乌兰县| 双鸭山市| 饶阳县| 汶上县| 广平县| 辰溪县| 郓城县| 新建县| 莒南县| 永丰县| 方正县| 鹿泉市| 砚山县| 连平县| 温宿县| 商城县| 凤城市| 白河县| 合山市| 全州县| 铜梁县| 同心县|