Skip to content

Instantly share code, notes, and snippets.

View cyndibaby905's full-sized avatar

Fred Chen cyndibaby905

  • ByteDance
  • Beijing, China
View GitHub Profile
@cyndibaby905
cyndibaby905 / UIImage+WebP.h
Created January 6, 2014 10:27
WebP extension
@interface UIImage(WebP)
- (id)initWithWebPData:(NSData *)data;
@end
@cyndibaby905
cyndibaby905 / gist:8005951
Created December 17, 2013 14:43
Convert all frames of a gif pic to pngs
convert -coalesce googlechrome.gif target.png
@cyndibaby905
cyndibaby905 / gist:8003205
Created December 17, 2013 11:00
Draw circle with two colors
CGFloat borderWidth = 3.f;
CGFloat circleRadius = self.bounds.size.width / 2 - borderWidth;
CGPoint circleCenter = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [[UIColor colorWithRed:255.0/255.0 green:210.0/255.0 blue:60.0/255.0 alpha:1] CGColor]);
UIBezierPath *firstHalf = [UIBezierPath bezierPath];
@cyndibaby905
cyndibaby905 / gist:7781375
Created December 4, 2013 02:34
Animation issues
CABasicAnimation *positionAnimation;
positionAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
positionAnimation.fromValue = [NSValue valueWithCGPoint:fromPosition];
positionAnimation.toValue = [NSValue valueWithCGPoint:toPosition];
CABasicAnimation *alphaAnimation;
alphaAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
alphaAnimation.fromValue = [NSNumber numberWithFloat:fromAlpha];
alphaAnimation.toValue = [NSNumber numberWithFloat:toAlpha];
//
// KSDIdlingWindow.h
//
// Created by Brian King on 4/13/10.
// Copyright 2010 King Software Designs. All rights reserved.
//
// Based off:
// http://stackoverflow.com/questions/273450/iphone-detecting-user-inactivity-idle-time-since-last-screen-touch
//