移动UIImage时钟指针?

时间:2014-04-21 18:38:51

标签: ios rotation uiimage geometry clock

我正在研究用X代码创建模拟时钟,并且在解决如何全天候旋转时钟时遇到问题。我使用png文件作为时钟指针 老实说,我不确定除了外观之外如何添加时钟方面。我在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代码

import

@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

0 个答案:

没有答案