This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_maskLayer=[[CAGradientLayer layer]retain]; | |
_maskLayer.frame=self.bounds; | |
_maskLayer.colors=@[(id)[UIColor colorWithRed:255/255.0f green:255.0f/255.0f blue:255/255.0f alpha:1.0f].CGColor, | |
(id)[UIColor colorWithRed:255/255.0f green:255.0f/255.0f blue:255/255.0f alpha:0.0f].CGColor]; | |
_maskLayer.startPoint=CGPointMake(0.5, 0.3f); | |
_maskLayer.endPoint=CGPointMake(0.5f, 1.0f); | |
_maskLayer.locations=@[@0.0f,@1.0f]; | |
self.layer.mask=_maskLayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(UIImage*)makeGradientImage{ | |
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 1.0f); | |
CGContextRef context=UIGraphicsGetCurrentContext(); | |
CGContextSaveGState(context); | |
CGGradientRef myGradient; | |
CGColorSpaceRef myColorspace; | |
size_t num_locations = 2; | |
CGFloat locations[2] = { 0.0, 1.0 }; | |
CGFloat components[8] = { 0.0,0.0,0.0, 0.0, // Start color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(UIImage*)makeGradientImage{ | |
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 1.0f); | |
CGContextRef context=UIGraphicsGetCurrentContext(); | |
CGContextSaveGState(context); | |
CGGradientRef myGradient; | |
CGColorSpaceRef myColorspace; | |
size_t num_locations = 2; | |
CGFloat locations[2] = { 0.2, 0.9}; | |
CGFloat components[8] = { 0.0,0.0,0.0, 0.0, // Start color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///为UIView创建一个截图 | |
static inline UIImage* WKFlip_make_image_for_view(UIView* view){ | |
double startTime=CFAbsoluteTimeGetCurrent(); | |
if(UIGraphicsBeginImageContextWithOptions != NULL){ | |
UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0); | |
} else { | |
UIGraphicsBeginImageContext(view.frame.size); | |
} | |
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage* image=UIGraphicsGetImageFromCurrentImageContext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///分割图片 | |
static inline NSArray* WKFlip_make_hsplit_images_for_image(UIImage* image){ | |
CGSize halfSize=CGSizeMake(image.size.width, image.size.height/2); | |
UIGraphicsBeginImageContext(halfSize); | |
CGContextRef context=UIGraphicsGetCurrentContext(); | |
CGContextSaveGState(context); | |
// Flip the coordinate system | |
CGContextSetTextMatrix(context, CGAffineTransformIdentity); // 2-1 | |
CGContextTranslateCTM(context, 0, halfSize.height); // 3-1 | |
CGContextScaleCTM(context, 1.0, -1.0); // 4-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define PATH_HOME NSHomeDirectory() ///获取主目录 | |
#define PATH_TEMP NSTemporaryDirectory() ///获取临时目录 | |
#define PATH_DOCUMENT NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDirectory, YES)[0] ///获取文档目录 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 去掉前部的 | |
void ltrim(char *s) | |
{ | |
long l=0,p=0,k=0; | |
l = strlen(s); | |
if( l == 0 ) return; | |
p = 0; | |
while( s[p] == ' ' || s[p] == '\t' ) p++; | |
if( p == 0 ) return; | |
while( s[k] != '\0') s[k++] = s[p++]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void strRev(char *s) | |
{ | |
char temp, *end = s + strlen(s) - 1; | |
while( end > s) | |
{ | |
temp = *s; | |
*s = *end; | |
*end = temp; | |
--end; | |
++s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double startTime=CFAbsoluteTimeGetCurrent(); | |
NSLog(@"duration:%f",CFAbsoluteTimeGetCurrent()-startTime); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CATransaction begin]; | |
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; | |
self.transform=WKFlipCATransform3DPerspectSimpleWithRotate(rotateDegree); | |
... | |
[CATransaction commit]; |
OlderNewer