Created
May 19, 2013 04:58
-
-
Save shoya140/5606741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// CountSample | |
// | |
// Created by Shoya Ishimaru on 13/03/30. | |
// Copyright (c) 2013年 Shoya Ishimaru. All rights reserved. | |
// | |
#import "ViewController.h" | |
@interface ViewController (){ | |
int counterNumber; | |
} | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
counterNumber = 0; | |
[self setNumberColor:counterNumber]; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (IBAction)buttonWasPushed:(id)sender { | |
counterNumber ++; | |
[self setNumberColor:counterNumber]; | |
} | |
- (IBAction)clearWasPushed:(id)sender { | |
counterNumber = 0; | |
[self setNumberColor:counterNumber]; | |
} | |
- (void)setNumberColor:(int)number{ | |
self.numberLabel.textColor = [UIColor blackColor]; | |
self.numberLabel.text = [NSString stringWithFormat:@"%d",counterNumber]; | |
int tmp = counterNumber; | |
while (tmp != 0) { | |
if (tmp%10 == 3) { | |
self.numberLabel.textColor = [UIColor redColor]; | |
return; | |
} | |
tmp = tmp/10; | |
} | |
if (number%3 == 0) { | |
self.numberLabel.textColor = [UIColor redColor]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment