Reputation: 133
how can i implement an NSArray in this method (instead of just defining each one of the objects).
code:
- (void) fadeOutShuffleAnimation
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.8];
[UIView setAnimationDelegate:self];
juw1.alpha = 0.0;
juw2.alpha = 0.0;
juw3.alpha = 0.0;
juw4.alpha = 0.0;
...
[UIView commitAnimations];
}
Upvotes: 1
Views: 225
Reputation: 96994
// initialize _juwArray array
NSMutableArray *_juwArray = [NSMutableArray arrayWithCapacity:size];
for (NSInteger index = 0; index < size; index++) {
// instantiate _juw instance and add it to _juwArray
// assuming conformation to NSCopying/NSMutableCopying protocols
// or that Juw is a subclass of UIView
[_juwArray addObject:_juw];
}
// set alpha values
for (NSInteger index = 0; index < size; index++) {
[((Juw *)[_juwArray objectAtIndex:index]) setAlpha:0.0];
}
Upvotes: 1
Reputation: 3441
Maybe take all objects from view.subviews and set alpha to 0
example:
for(UIView *v in self.view.subviews) {
if([v isKindOfObject:[UIImageView class]] ) {
v.alpha = 0;
}
}
Upvotes: 1
Reputation: 170859
if juw* are uiviews (or uiview subclasses) you can assign them unique tag property and loop through them like:
for (loop tag condition){
[parentView viewWithTag: tag].alpha = 0;
}
So actually after you create your items and add to parentView as subviews you might not need to store items as you can always get them using their tags.
Upvotes: 2