Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backgroundColor support. #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions OLImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ - (void)displayLayer:(CALayer *)layer
layer.contents = (__bridge id)([[self.animatedImage.images objectAtIndex:self.currentFrameIndex] CGImage]);
}

- (void)setBackgroundColor:(UIColor *)backgroundColor
{
[super setBackgroundColor:backgroundColor];
self.layer.backgroundColor = [backgroundColor CGColor];
}

- (void)didMoveToWindow
{
[super didMoveToWindow];
Expand Down
Binary file modified OLImageViewDemo/Images/google-io.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OLImageViewDemo/Images/google-io@2x.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OLImageViewDemo/Images/google-io@3x.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions OLImageViewDemo/OLAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[magicAnimatedVC.view addSubview:Aimv];

Aimv = [[OLImageView alloc] initWithImage:[OLImage imageNamed:@"google-io"]];
Aimv.contentMode = UIViewContentModeCenter;
Aimv.clipsToBounds = YES;
Aimv.backgroundColor = [UIColor cyanColor];
[Aimv setFrame:CGRectMake(0, 160, 160, 160)];
[Aimv setUserInteractionEnabled:YES];
[Aimv addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]];
Expand Down Expand Up @@ -115,6 +118,8 @@ - (void)handleTap:(UITapGestureRecognizer *)gestRecon
NSLog(@"STOP");
[imageView stopAnimating];
} else {
CGFloat randomHue = (CGFloat)arc4random_uniform(255) / 255;
imageView.backgroundColor = [UIColor colorWithHue:randomHue saturation:1 brightness:1 alpha:1];
self.running = YES;
NSLog(@"START");
[imageView startAnimating];
Expand Down