@ Interface timingcurveviewcontroller: uiviewcontroller {
Iboutlet uiimageview * basketball;
}
-(Void) touchesended :( nsset *) touches withevent :( uievent *) event {
[Uiview beginanimations: @ "movement" context: Nil];
[Uiview setanimationcurve: uiviewanimationcurveeasein]; // <label id = "code. timingcurve. easein"/>
[Uiview setanimationduration: 1.0f];
[Uiview setanimationrepeatcount: 3];
[Uiview setanimationrepeatautoreverses: Yes];
Cgpoint center = Basketball. Center;
If (center. Y> 85.0f ){
Center. Y-= 295.0f;
Basketball. Center = center;
} Else {
Center. Y + = 295.0f;
Basketball. Center = center;
}
[Uiview commitanimations];
}
-(Void) viewdidload {
[Super viewdidload];
Self. View. backgroundcolor = [self colorwithrgbhexstring: @ "# abcdef"];
}
-(Uicolor *) colorwithrgbhexstring :( nsstring *) rgbcolor {
Nsstring * cstring = rgbcolor;
// Remove spaces and uppercase nscharactersetwhitespaceandnewlinecharacterset
Cstring = [[cstring stringbytrimmingcharactersinset: [nscharacterset whitespaceandnewlinecharacterset] uppercasestring];
If ([cstring length] <6 ){
// Returns the default color.
Return [uicolor redcolor];
}
If ([cstring hasprefix: @ "0x"]) {
Cstring = [cstring substringfromindex: 2];
} Else if ([cstring hasprefix: @ "#"]) {
Cstring = [cstring substringfromindex: 1];
}
If ([cstring length]! = 6 ){
// Returns the default color.
Return [uicolor redcolor];
}
Nsange range;
Range. Length = 2;
Range. Location = 0;
Nsstring * rstring = [cstring substringwithrange: range];
Range. Location = 2;
Nsstring * gstring = [cstring substringwithrange: range];
Range. Location = 4;
Nsstring * bstring = [cstring substringwithrange: range];
Unsigned int R, G, B;
[[Ns1_scannerwithstring: rstring] scanhexint: & R];
[[Ns1_scannerwithstring: gstring] scanhexint: & G];
[[Ns1_scannerwithstring: bstring] scanhexint: & B];
Return [uicolor colorwithred :( float) r/255.0 green :( float) g/255.0 blue :( float) B/255.0 ALPHA: 1.0f];
}