)duration; + (SCNAction *)moveBy:(SCNVector3)delta duration:(NSTimeInterval)duration; b.移动到指定的位置 + (SCNAction *)moveTo:(SCNVector3)location duration:(NSTimeInterval)duration; 旋转 a.相对于当前位置旋转 + (SCNAction *)rotateByX:(CGFloat)xAngle y:(CGFloat)yAngle z:(CGFloat)zAngle duration:(NSTimeInterval)duration; + :(NSTimeInterval)sec; b.透明减小到0 + (SCNAction *)fadeOutWithDuration:(NSTimeInterval)sec; c.透明度逐渐递增 + (SCNAction )sec; b.等待随机时间 + (SCNAction *)waitForDuration:(NSTimeInterval)sec withRange:(NSTimeInterval)durationRange
+ scheduledTimerWithTimeInterval: invocation: repeats: + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval + timerWithTimeInterval: invocation: repeats: + (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti invocation run]; 停止 Timer – invalidate Timer设置 – isValid – fireDate – setFireDate: – timeInterval – userInfo NSTimeInterval 类:是一个浮点数字,用来定义秒 例子: iphone为我们提供了一个很强大得时间定时器 NSTimer 他可以完成任何定时功能: 我们使用起来也很简单,只要记住三要素就可以,具体得三要素是:时间间隔NSTimeInterval 浮点型,事件代理 delegate和事件处理方法@selector();就可以用 + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)
:(NSTimeInterval)sec; + (SKTransition *)fadeWithColor:(SKColor *)color duration:(NSTimeInterval)sec; :(NSTimeInterval)sec; + (SKTransition *)revealWithDirection:(SKTransitionDirection)direction duration NSTimeInterval)sec; + (SKTransition *)doorsOpenHorizontalWithDuration:(NSTimeInterval)sec; + (SKTransition :(NSTimeInterval)sec; + (SKTransition *)doorsCloseVerticalWithDuration:(NSTimeInterval)sec; + (SKTransition *)doorwayWithDuration:(NSTimeInterval)sec; 动画效果还挺多的,就不一一演示了,我在使用这个方法的时候,遇到了一个大坑。
//获取gif图片的总时长和循环次数 - (NSTimeInterval)durationForGifData:(NSData *)data{ //将GIF图片转换成对应的图片源 CGImageSourceRef CGImageSourceGetCount(gifSource); //定义数组存储拆分出来的图片 NSMutableArray* frames = [[NSMutableArray alloc] init]; NSTimeInterval UIImage imageWithCGImage:imageRef]; //将图片加入数组中 [frames addObject:imageName]; NSTimeInterval 每一帧时间间隔.png //获取GIF图片每帧的时长 - (NSTimeInterval)gifImageDeleyTime:(CGImageSourceRef)imageSource index:( NSInteger)index { NSTimeInterval duration = 0; CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex
UIView动画 @interface UIView(UIViewAnimationWithBlocks) + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations (void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); + (void)animateWithDuration:(NSTimeInterval )duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity )duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void
尤其是小型游戏,然而对于初学者时常会注意不到其中的内存释放问题,将其基本用法总结如下: 一、初始化方法:有五种初始化方法,分别是 + (NSTimer *)timerWithTimeInterval:(NSTimeInterval :NSDefaultRunLoopMode]; //开始循环 [timer fire]; } + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval scheduledTimerWithTimeInterval:1 invocation:invo repeats:YES]; + (NSTimer *)timerWithTimeInterval:(NSTimeInterval self selector:@selector(myLog) userInfo:nil repeats:NO] + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval @property NSTimeInterval tolerance; 这是7.0之后新增的一个属性,因为NSTimer并不完全精准,通过这个值设置误差范围。
没有必要啊,这就是考验我们对时间的操作,代码实现如下: 代码实现 #pragma mark -- 判断是否弹出广告 - (BOOL)isLoadAdvertIn { //当前时间戳 NSTimeInterval interval = [[NSDate date] timeIntervalSince1970]; NSTimeInterval time00 = [GDDateUtil setCurrentlyDaySetHour :00 setMinute:00 setSec:00];//当前天00点的时间戳 NSTimeInterval time12 = [GDDateUtil setCurrentlyDaySetHour :12 setMinute:00 setSec:00];//当前天12点的时间戳 NSTimeInterval time14 = [GDDateUtil setCurrentlyDaySetHour :14 setMinute:00 setSec:00];//当前天14点的时间戳 NSTimeInterval time24 = [GDDateUtil setCurrentlyDaySetHour
instancetype)requestWithURL:(NSURL *)URL cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval instancetype)initWithURL:(NSURL *)URL cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval */ @property (readonly) NSURLRequestCachePolicy cachePolicy; //只读属性 获取请求的超时时限 @property (readonly) NSTimeInterval nullable, copy) NSURL *URL; //设置请求的缓存策略 @property NSURLRequestCachePolicy cachePolicy; //设置超时时间 @property NSTimeInterval
二、UIView动画的几个方法 + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations UIView animateWithDuration:1 animations:^{ _myView.alpha=0; }]; + (void)animateWithDuration:(NSTimeInterval if (finished) { _myView.alpha=1; } }]; + (void)animateWithDuration:(NSTimeInterval )duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping
)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval 视图旋转之前自动调用 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval
从现在开始的24小时 NSTimeInterval secondsPerDay = 24*60*60; NSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow 根据已有日期创建日期 NSTimeInterval secondsPerDay1 = 24*60*60; NSDate *now = [NSDate date]; NSDate 两个日期之间相隔多少秒 NSTimeInterval secondsBetweenDates= [yesterDay timeIntervalSinceDate:now]; NSLog(
创建当前时间 NSDate *date = [NSDate date]; 从现在开始的24小时 NSTimeInterval a_day = 24*60*60; NSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:a_day]; 根据已有日期创建日期 NSTimeInterval a_day = 24*60 laterDate = [tomorrow laterDate:date]; NSLog(@"laterDate = %@",laterDate); //两个日期之间相隔多少秒 NSTimeInterval
创建当前时间 NSDate *date = [NSDate date]; 从现在开始的24小时 NSTimeInterval a_day = 24*60*60; NSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:a_day]; 根据已有日期创建日期 NSTimeInterval a_day = 24*60 laterDate = [tomorrow laterDate:date]; NSLog(@"laterDate = %@",laterDate); //两个日期之间相隔多少秒 NSTimeInterval
startDate =[date dateFromString:startTime]; NSDate *endDdate = [date dateFromString:endTime]; NSTimeInterval startInterval = [startDate timeIntervalSince1970]*1; NSTimeInterval endInterval = [endDdate timeIntervalSince1970 ]*1; NSTimeInterval value = endInterval - startInterval; // 天 int day = (int)value /
-- 下面说说NSTImer, 一样我们直接看头文件并用注释说明 @interface NSTimer : NSObject + (NSTimer *)timerWithTimeInterval:(NSTimeInterval 响应事件用的NSIvocation, 系统为自动帮你将timer添加到currentRunLoop中,defaultMode + (NSTimer *)timerWithTimeInterval:(NSTimeInterval PerformanceSelector, userInfo中可以用来传参数,需要手动添加到RunLoop中 + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval userInfo可以用来传递参数, 系统会自动帮你将timer添加到currentRunLoop中, defaultMode + (NSTimer *)timerWithTimeInterval:(NSTimeInterval timeInterval; //只读属性, 获取当前timer的触发间隔 @property NSTimeInterval tolerance NS_AVAILABLE(10_9, 7_0);
MPMovieSourceTypeFile, // 文件类型 MPMovieSourceTypeStreaming // 数据流 }; @property (nonatomic, readonly) NSTimeInterval duration; 视频文件的时长 @property (nonatomic, readonly) NSTimeInterval playableDuration; 缓存完成能够播放的时长 @property (nonatomic, readonly) CGSize naturalSize; 视频的原始大小 @property (nonatomic) NSTimeInterval initialPlaybackTime ; 播放器开始播放的时间 @property (nonatomic) NSTimeInterval endPlaybackTime; 播放器结束播放的时间 @property (nonatomic) BOOL play; //调用此方法进行视频播放的暂停操作 - (void)pause; //调用此方法停止视频播放 - (void)stop; //当前视频已播放的时间 @property(nonatomic) NSTimeInterval
setAnimationDuration:5]; 提交动画(真正开始做动画) [UIView commitAnimations]; 13 块动画 +(void)animateWithDuration:(NSTimeInterval void))animations completion:(void (^__nullable)(BOOL finished))completion; +(void)animateWithDuration:(NSTimeInterval )duration animations:(void (^)(void))animations; +(void)animateWithDuration:(NSTimeInterval)**duration ** delay:(NSTimeInterval)**delay** usingSpringWithDamping:(CGFloat)**dampingRatio** initialSpringVelocity
- (BOOL)prepareToPlay; 开始播放音频 - (BOOL)play; 在一段时间间隔后播放 - (BOOL)playAtTime:(NSTimeInterval)time; 暂停播放, BOOL playing; 获取当前音频声道数 @property(readonly) NSUInteger numberOfChannels; 获取当前音频时长 @property(readonly) NSTimeInterval 设置播放速度,1为正常,0.5为一半速度,2.0为2倍速度 @property float rate; 设置当前播放的时间点 @property NSTimeInterval currentTime;
两个方法: + (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions + (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration
kCVPixelBufferLock_ReadOnly); CVPixelBufferLockBaseAddress(dstPixelBuffer, kCVPixelBufferLock_ReadOnly); NSTimeInterval width:CVPixelBufferGetHeight(srcPixelBuffer) height:CVPixelBufferGetWidth(srcPixelBuffer)]; NSTimeInterval dstPixelBuffer),CVPixelBufferGetHeight(srcPixelBuffer),CVPixelBufferGetWidth(srcPixelBuffer)); NSTimeInterval CVPixelBufferGetWidthOfPlane(srcPixelBuffer, 0), CVPixelBufferGetHeightOfPlane(srcPixelBuffer, 0)); NSTimeInterval CVPixelBufferGetWidthOfPlane(srcPixelBuffer, 0), CVPixelBufferGetHeightOfPlane(srcPixelBuffer, 0)); NSTimeInterval