Curnelious
Curnelious

Reputation: 1

fill part of a UIView with color with animation

I need to create effect of filling a UIView with color, with animation. For example as a battery image is filled with background color .

So i can see the problem as 2 :

  1. background color of a UIView but only part of it ( 10% / 45% /etc )
  2. make it with animation

How would you color part of a UIView natively? (obj-C)

UIView *view=[UIView alloc] init];
view.backgroundColor=[UIColor redColor]; //is colouring all of it .

creating 2 views is a problem,because i need to animate the whole thing as it fills the color .

Upvotes: 0

Views: 790

Answers (1)

Nils Ziehn
Nils Ziehn

Reputation: 4331

You would use two views, which is not a problem if you just put the second view as a subview into the first. This way you can just animate outer view and the inner will follow.

To show you battery level you would just animate the frame of the inner view.

Upvotes: 1

Related Questions