// 애니메이션
- (void)viewDidLoad {
imgView.animationImages=[NSArray arrayWithObjects:
[UIImage imageNamed:@"lori.png"],
[UIImage imageNamed:@"miranda.png"],
[UIImage imageNamed:@"taylor.png"],
[UIImage imageNamed:@"ingrid.png"],
[UIImage imageNamed:@"kasey.png"],
[UIImage imageNamed:@"wreckers.png"], nil];
imgView.animationDuration=20.0;
imgView.animationRepeatCount=0;
[imgView startAnimating];
[self.view addSubview:imgView];
[imgView release];
//The timers time interval is the imageViews animation duration devided by the number of images in the animationImages array. 20/5 = 4
NSTimer *timer = [NSTimer timerWithTimeInterval:4.0
target:self
selector:@selector(onTimer)
userInfo:nil
repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[timer fire];
[super viewDidLoad];
}
//It is important that the animation durations within these animation blocks add up to 4
//(the time interval of the timer). If you change the time interval then the time intervals
//in these blocks must also be changed to refelect the amount of time an image is displayed.
//Failing to do this will mean your fading animation will go out of phase with the switching of images.
-(void)onTimer{
[UIView animateWithDuration:3.0 animations:^{
imgView.alpha = 0.0;
}];
[UIView animateWithDuration:1.0 animations:^{
imgView.alpha = 1.0;
}];
}
------------- 시간비교
//현재시간
NSDate* dateFrom = [NSDate date];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components = [calendar components:NSYearCalendarUnit |
NSMonthCalendarUnit |
NSDayCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit fromDate:dateFrom];
int year = [components year];
int month = [components month];
int day = [components day];
int hour = [components hour];
int minute = [components minute];
int second = [components second];
NSDate *date;
NSDateComponents *com;
NSDateFormatter *formatter;
com = [[NSDateComponents alloc] init];
[com setYear:year];
[com setMonth:month];
[com setDay:day];
[com setHour:hour];
[com setMinute:minute];
[com setSecond:second];
date1 = [[NSCalendar currentCalendar] dateFromComponents:com];
formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSLog(@"now time%@", [formatter stringFromDate:date1]);
com = [[NSDateComponents alloc] init];
[com setYear:year];
[com setMonth:month];
[com setDay:day];
[com setHour:hour];
[com setMinute:5];
[com setSecond:second];
date2 = [[NSCalendar currentCalendar] dateFromComponents:com];
NSLog(@"now time%@", [formatter stringFromDate:date2]);
NSTimeInterval secondsBetweenDates = [date2 timeIntervalSinceDate:date1];
NSLog(@"NSTimeInterval%f", secondsBetweenDates); int year = [components year];
int month = [components month];
int day = [components day];
int hour = [components hour];
int minute = [components minute];
int second = [components second];
NSLog(@"minute = %i",minute);
'개발도구 > iOS - 아이폰 개발' 카테고리의 다른 글
[ios] 화면 세로 고정 ios (0) | 2013.02.15 |
---|---|
[ios] 아이폰 디자인 가이드 (0) | 2013.02.04 |
[ios] view 투명설정 (0) | 2013.01.29 |
[ios] image cache, 이미지 캐쉬 (0) | 2013.01.28 |
[iOS] View 이동 전환 하기 총정리 (0) | 2013.01.22 |