Ios 移动图像时钟指针?
我正在用X代码创建一个模拟时钟,但在弄清楚如何24小时旋转时钟指针时遇到了问题。我使用png文件作为时钟指针。Ios 移动图像时钟指针?,ios,rotation,uiimage,geometry,clock,Ios,Rotation,Uiimage,Geometry,Clock,我正在用X代码创建一个模拟时钟,但在弄清楚如何24小时旋转时钟指针时遇到了问题。我使用png文件作为时钟指针。 我真的不知道如何添加时钟方面,除了它的外观。我在Youtube上找到的每一个教程都重复相同的代码,这并不是我所需要的,而且它通常只有一年的历史,如果不是更久的话 这是我的代码 // // ViewController.m // AnalogClock // // Created by edragongaming on 4/7/14. // Copyright (c
我真的不知道如何添加时钟方面,除了它的外观。我在Youtube上找到的每一个教程都重复相同的代码,这并不是我所需要的,而且它通常只有一年的历史,如果不是更久的话 这是我的代码
//
// ViewController.m
// AnalogClock
//
// Created by edragongaming on 4/7/14.
// Copyright (c) 2014 edragon. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(void) countup
{
MainInt += 1;
seconds.text = [NSString stringWithFormat:@"%i", MainInt];
}
-(IBAction)start:(id)sender
{
MainInt = 0;
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countup) userInfo:nil repeats:YES];
}
@synthesize label;
-(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//label.text = @"Bye";
[self updateTime];
}
-(void)updateTime
{
NSDateFormatter *dateFormat = [ [NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"hh:mm:ss"];
label.text = [dateFormat stringFromDate: [NSDate date] ];
//call updateTime after 1 second
[self performSelector:@selector(updateTime) withObject:self afterDelay:1.0];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
这是.h代码
进口
你显示钟面图像的代码在哪里?试图显示时钟指针图像的代码在哪里?您发布的代码只是更新标签。可能重复
@interface ViewController : UIViewController
{
IBOutlet UIImageView *animatedImage;
IBOutlet UILabel *seconds;
NSTimer *timer;
int MainInt;
}
-(IBAction)start:(id)sender;
-(IBAction)startAnimating;
-(void)countup;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet
UIImageView *hourHand;
@property (weak, nonatomic) IBOutlet UIImageView *minuteHand;
@property (weak, nonatomic) IBOutlet UIImageView *secondHand;
@end