0
我正試圖通過縮放欄(滑塊)和翻譯endcap來創建一個動畫條形圖。 Endcap按預期工作,但是,當我嘗試水平縮放時,「滑塊」會轉換。iPad:如何使用CGAffineTransformScale創建動態條形圖?
-(void) animateBarOpen: (NSInteger) rowIndex {
NSLog(@"%s: row=%d %@", __FUNCTION__, rowIndex, [self.values objectAtIndex:rowIndex]);
NSMutableDictionary *row = [self.values objectAtIndex:rowIndex];
UIImageView *slider = [row objectForKey:@"slider"];
UIImageView *endCap = [row objectForKey:@"image"];
UILabel *labelInfo = [row objectForKey:@"label"];
[labelInfo setText: [NSString stringWithFormat: @"%@ %@", [row objectForKey:@"quantity"], [row objectForKey:@"color"]]];
[labelInfo setTextColor: productColor];
float quantity = [(NSNumber*) [row objectForKey:@"quantity"] floatValue];
float tx = 10.0f * quantity;
float sx = -40.0f * quantity;
[UIView beginAnimations:@"open" context:nil];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
slider.transform = CGAffineTransformScale(CGAffineTransformIdentity, sx, 1.0f);
endCap.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, tx, 0.0f);
labelInfo.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, tx, 0.0f);
[UIView commitAnimations];
}