我想在 for 语句中包含更多语句。现在我这样做:
for (UIImageView* img in imageArray){
for (UITextField* txt in messagename){
}}
...但是以这种方式它多次重复代码,所以我尝试了这个:
for (UIImageView* img in imageArray)||(UITextField* txt in messagename)
但它不起作用!
编辑:
for (UIImageView* img in imageArray)||(UITextField* txt in messagename) {
img.hidden = YES;
CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[anim setToValue:[NSNumber numberWithFloat:0.0f]];
[anim setFromValue:[NSNumber numberWithDouble:M_PI/80]]; // rotation angle
[anim setDuration:0.1];
[anim setRepeatCount:NSUIntegerMax];
[anim setAutoreverses:YES];
//[img.layer addAnimation:anim forKey:@"iconShake"];
UIImage *tmpImage = [UIImage imageNamed:@"message small type 2.png"];
CGRect cellRectangle;
cellRectangle = CGRectMake(20, img.frame.origin.y + 45, 710, 60);
UIImageView *dragger = [[Draggable alloc] initWithFrame:cellRectangle];
[dragger setImage:tmpImage];
[dragger setUserInteractionEnabled:YES];
[self.view addSubview:dragger];
[wobbleImage addObject: dragger];
Draggable* sharedSingleton = [Draggable sharedManagerDraggable];
sharedSingleton.namePassedToDraggable = txt.text;
dragger.tag = img.tag;
dragger.layer.cornerRadius = 10; // this value vary as per your desire
dragger.clipsToBounds = YES;
[dragger.layer addAnimation:anim forKey:@"iconShake"];
}