Putting attenuation into attenuation Effect on object C

I want this to be the background in my iPad app. I build everything in objective C (native application)

I need a little help figuring out how to animate each of the triangles above the image (overlay) so that it disappears and exits independently of each other, the goal is to make a constant flickering effect so that the image does not feel sos tatic. Do I need to animate every triangle? Is there any algorithm I should look at, so it seems random, but not.

Here is the background image

enter image description here

I need to be guided by where to start and how to approach this problem, and feedback will be appreciated.

+4
source share
2 answers

a) . My advice is to use the UIViewAnimationWithBlocks introduced in iOS 4. If you have a clear understanding of the blocks, they can be very helpful. Here is an example that I created in just 5 minutes to illustrate:

typedef void(^FadeInOutBlock)(void); @interface PMViewController () @property (nonatomic, copy) FadeInOutBlock fadeInOutBlock; @end 

Here we declare a typedef to save us the trouble of executing block syntax over and over. We also create a property to hold the animation block.

 @implementation PMViewController @synthesize myView; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. __block PMViewController *_self = self; self.fadeInOutBlock = ^{ [UIView animateWithDuration:0.5f animations:^{ // fade out effect _self.myView.alpha = 0.0f; } completion:^(BOOL success){ [UIView animateWithDuration:0.5f animations:^{ // fade in effect _self.myView.alpha = 1.0f; } completion:^(BOOL success){ // recursively fire a new animation if (_self.fadeInOutBlock) _self.fadeInOutBlock(); }]; }]; }; } 

We create animations in animations. You start by fading out when myView alpha is reduced to 0.0f in 0.5f seconds. After its completion, the second animation will be launched, restoring the alpha for myView to 1.0f and, finally, releasing the first animation again. (Animception)

 - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (self.fadeInOutBlock) self.fadeInOutBlock(); } @end 

And finally, at first glance, you first launched it.

b)

Now, for the flickering animation you mention, I suggest you split each triangle into its own UIView and use the technique above using different durations and alpha.

If you have many small UIViews, group them into a larger UIView (using the addSubview method) and apply the animation to these β€œcontainers” of UIViews.

For example, you can have four separate UIViews containers that have separate separate UIViews. You can then create four animation blocks, one for each container, and then apply animation to them. I bet, experimenting with this, you can create good effects.

+4
source

You can do this without any special libraries. So you need to create a black UIView with alpha 0. Then create an NSTimer that increases the alpha of the UIView .

0
source

Source: https://habr.com/ru/post/1432618/


All Articles