Skip to content

Instantly share code, notes, and snippets.

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// 拼车族导航
CarSharingViewController* carSharingViewController = [[CarSharingViewController alloc] init];
UINavigationController* mainNav = [[UINavigationController alloc] initWithRootViewController:carSharingViewController];
UIImage *image = [UIImage imageNamed:@"CarSharingNavBG.png"];
[mainNav.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
// 立即用车导航
///////////////////////////////////////////////////////////////////////////////////////////////////
- (IBAction)showModeButtonPressed:(id)sender {
NewsCenterViewController* newViewcontroller = [[NewsCenterViewController alloc] initWithNibName:@"NewsCenterViewController" bundle:nil];
newViewcontroller.delegate = self;
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:newViewcontroller];
[self pushNavigationController:nav];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
CABasicAnimation* theAnimaiton;
theAnimaiton = [CABasicAnimationanimationWithKeyPath:@"transform.translation.x"];
theAnimaiton.fromValue = [NSNumber numberWithInt:-30];
theAnimaiton.toValue = [NSNumber numberWithInt:200];
theAnimaiton.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseIn];
theAnimaiton.duration = 0.6;
theAnimaiton.delegate = self;
theAnimaiton.fillMode = kCAFillModeForwards;
theAnimaiton.removedOnCompletion = NO; // 设置为NO,保证动画不被移除,保证animation上FillMode的值有效
theAnimaiton.autoreverses = YES;
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
UIImage* image = [UIImage imageNamed:@"avatar.png"];
CGPathRef visiblePath = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:10].CGPath;
CGContextAddPath(context, visiblePath);
CGContextClip(context);
[image drawInRect:rect];
#define NavigationBar_HEIGHT 44
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define SAFE_RELEASE(x) [x release];x=nil
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion])
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
#define BACKGROUND_COLOR [UIColor colorWithRed:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]
//use dlog to print while in debug model
-(void)viewDidLoad{
[super viewDidLoad];
UIButton *btnFlip = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btnFlip.frame = CGRectMake(10, 10, 50, 30);
[btnFlip setTitle:@"flip" forState:UIControlStateNormal];
[btnFlip addTarget:self action:@selector(flip) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnFlip];
panel = [[UIView alloc] initWithFrame:CGRectMake(10, 40, 300,300)];
panel.backgroundColor = [UIColor darkGrayColor];
/* 过渡效果
fade //交叉淡化过渡(不支持过渡方向)
push //新视图把旧视图推出去
moveIn //新视图移到旧视图上面,
reveal //将旧视图移开,显示下面的新视图
cube //立方体翻滚效果
oglFlip //上下左右翻转效果
suckEffect //收缩效果,如一块布被抽走(不支持过渡方向)
rippleEffect //滴水效果(不支持过渡方向)
pageCurl //向上翻页效果
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];
#import "ViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface ViewController () {
CALayer* _myLayer;
BOOL _isShowed;
BOOL _isAnimationRunning;
}
[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