Graphics Reference
In-Depth Information
The duration and repeatCount properties both default to zero. This doesn't mean that the
animation has a duration of zero seconds, or repeats zero times; a value of zero in this case,
is just used to mean “use the defaults,” which are 0.25 seconds and one iteration,
respectively. You can try out various values for these properties using the simple test
program in Listing 9.1. Figure 9.1 shows the program interface.
Listing 9.1 Testing the duration and repeatCount Properties
@interface ViewController ()
@property ( nonatomic , weak ) IBOutlet UIView *containerView;
@property ( nonatomic , weak ) IBOutlet UITextField *durationField;
@property ( nonatomic , weak ) IBOutlet UITextField *repeatField;
@property ( nonatomic , weak ) IBOutlet UIButton *startButton;
@property ( nonatomic , strong ) CALayer *shipLayer;
@end
@implementation ViewController
- ( void )viewDidLoad
{
[ super viewDidLoad ];
//add the ship
self .shipLayer = [ CALayer layer ];
self .shipLayer. frame = CGRectMake ( 0 , 0 , 128 , 128 );
self .shipLayer. position = CGPointMake ( 150 , 150 );
self .shipLayer. contents = ( __bridge id )[ UIImage imageNamed :
@"Ship.png" ]. CGImage ;
[ self .containerView. layer addSublayer : self .shipLayer];
}
- ( void )setControlsEnabled:( BOOL )enabled
{
for ( UIControl *control in @[ self .durationField,
self .repeatField, self .startButton ] )
{
control. enabled = enabled;
control. alpha = enabled? 1.0f : 0.25f ;
}
}
- ( IBAction )hideKeyboard
{
[ self . durationField resignFirstResponder ];
Search WWH ::




Custom Search