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
// | |
// ADBackFadeTransition.m | |
// AppLibrary | |
// | |
// Created by Patrick Nollet on 14/03/11. | |
// Copyright 2011 Applidium. All rights reserved. | |
// | |
#import "ADBackFadeTransition.h" | |
#import "ADDualTransition.h" |
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
/** | |
* 使用UIKit方式生成路径 | |
*/ | |
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
- (CGPathRef)renderPaperCurl:(UIView*)imgView { | |
CGSize size = imgView.bounds.size; | |
CGFloat curlFactor = 12.0f; | |
CGFloat shadowDepth = 4.0f; | |
CGFloat translationFactor = 6.0f; | |
UIBezierPath *path = [UIBezierPath bezierPath]; |
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
CGMutablePathRef thePath = CGPathCreateMutable(); | |
CGPathMoveToPoint(thePath, NULL, 15.0f, 10.0f); | |
CGPathAddQuadCurveToPoint(thePath, NULL, 155.0f, 450.0f, 295.0f,15.0f); | |
CGContextBeginPath(theContext); | |
CGContextAddPath(theContext, thePath); | |
CGContextSetStrokeColorWithColor(theContext, [UIColor greenColor].CGColor); | |
CGContextSetLineWidth(theContext, 3); | |
CGContextStrokePath(theContext); | |
CFRelease(thePath); |
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
CGMutablePathRef thePath = CGPathCreateMutable(); | |
CGPathMoveToPoint(thePath,NULL,15.0f,15.f); | |
CGPathAddCurveToPoint(thePath,NULL,15.f,250.0f,295.0f,250.0f,295.0f,15.0f); | |
CGContextSetStrokeColorWithColor(theContext, [UIColor greenColor].CGColor); | |
CGContextBeginPath(theContext); | |
CGContextAddPath(theContext, thePath); | |
CGContextSetLineWidth(theContext, 5); | |
CGContextStrokePath(theContext); | |
CFRelease(thePath); |
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
int ox = 50, oy = 50, r = 10, rw = 100, rh = 100; | |
CGMutablePathRef path = CGPathCreateMutable(); | |
CGPathMoveToPoint(path, NULL,ox, oy+r); | |
CGPathAddArcToPoint(path, NULL, ox, oy+rh, ox+r,oy+rh, r); | |
CGPathAddArcToPoint(path, NULL, ox+rw, oy+rh, ox+rw, oy+rh-r, r); | |
CGPathAddArcToPoint(path, NULL, ox+rw, oy, ox+rw-r, oy, r); | |
CGPathAddArcToPoint(path, NULL, ox, oy, ox,oy+r,r); | |
CGContextSetStrokeColorWithColor(theContext, [UIColor greenColor].CGColor); | |
CGContextBeginPath(theContext); | |
CGContextAddPath(theContext, path); |
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 double radians (double degrees) { return degrees * M_PI/180; } | |
@implementation MyLayerDelegate | |
- (void)drawLayer:(CALayer *)theLayer inContext:(CGContextRef)theContext { | |
CGContextSetStrokeColorWithColor(theContext, [UIColor greenColor].CGColor); | |
CGMutablePathRef path = createArcPathFromBottomOfRect(CGRectMake(0, 0, 100, 100), 50.0f); | |
CGContextBeginPath(theContext); | |
CGContextAddPath(theContext, path); | |
CGContextSetLineWidth(theContext, 3); | |
CGContextStrokePath(theContext); | |
CFRelease(path); |
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)drawRect:(CGRect)rect { | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
UIGraphicsPushContext(ctx); | |
CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f); // white color | |
CGContextSetShadow(ctx, CGSizeMake(2.0f, 2.0f), 2.0f); //也可以使用CGContextSetShadowWithColor (myContext, myShadowOffset, 5, myColor); | |
CGContextFillEllipseInRect(ctx, CGRectMake(10.0f, 10.0f, 100.0f, 100.0f)); // a white filled circle with a diameter of 100 pixels, centered in (60, 60) | |
UIGraphicsPopContext(); | |
} |
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
[self. ui_View.layer removeAllAnimations]; | |
CABasicAnimation *pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; | |
pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; | |
pulse.duration = 0.5 + (rand() % 10) * 0.05; | |
pulse.repeatCount = 1; | |
pulse.autoreverses = YES; | |
pulse.fromValue = [NSNumber numberWithFloat:.8]; | |
pulse.toValue = [NSNumber numberWithFloat:1.2]; | |
[self.ui_View.layer addAnimation:pulse forKey:nil]; | |
// bounds |
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
#import "ViewController.h" | |
#import <QuartzCore/QuartzCore.h> | |
@interface ViewController () { | |
CALayer* _myLayer; | |
BOOL _isShowed; | |
BOOL _isAnimationRunning; | |
} |
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
UIImageView *imageViewForAnimation = [[UIImageView alloc] initWithImage:imageToAnimate]; | |
imageViewForAnimation.alpha = 1.0f; | |
CGRect imageFrame = imageViewForAnimation.frame; | |
//Your image frame.origin from where the animation need to get start | |
CGPoint viewOrigin = imageViewForAnimation.frame.origin; | |
viewOrigin.y = viewOrigin.y + imageFrame.size.height / 2.0f; | |
viewOrigin.x = viewOrigin.x + imageFrame.size.width / 2.0f; | |
imageViewForAnimation.frame = imageFrame; | |
imageViewForAnimation.layer.position = viewOrigin; | |
[self.view addSubview:imageViewForAnimation]; |
OlderNewer