[UIViewbeginAnimations:nilcontext:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:2];
[self.viewsetAlpha:0.0];
[UIViewcommitAnimations];
[UIViewbeginAnimations:nilcontext:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[self.viewsetAlpha:1.0];
// [loginViewController.view setFrame:CGRectMake(0, 20, 320, 480)];
// TODO:中间可以修改很多东西,在这个view范围内
// 比如改变 scrollview 大小
//scrollView.contentInset=UIEdgeInsetsMake(60.0f,0.0f,0.0f,0.0f);
// [self addChildViewController:loginViewController];
[UIViewcommitAnimations];
如:
[UIViewbeginAnimations:nilcontext:NULL];
[UIViewsetAnimationDuration:.3];
[scrollViewsetContentInset:UIEdgeInsetsMake(0.0f,0.0f,0.0f,0.0f)];
[UIViewcommitAnimations];
CALayer 旋转效果:
CALayer*layer = [CALayerlayer];
layer.frame=CGRectMake(25.0f, frame.size.height-65.0f,30.0f,55.0f);
layer.contentsGravity=kCAGravityResizeAspect;
layer.contents= (id)[UIImageimageNamed:@"blueArrow.png"].CGImage;
[[selflayer]addSublayer:layer];
[CATransactionbegin];
[CATransactionsetAnimationDuration:FLIP_ANIMATION_DURATION];
layer.transform=CATransform3DMakeRotation((M_PI/180.0)
*180.0f,0.0f,0.0f,1.0f);
[CATransactioncommit];
把layer 加入到 UIView 里面,实现层的旋转动画效果。
设置uiView,成圆角矩形
今天要做一个button, 使用系统的没啥意思,感觉学不到新东西,所以自己做uiview,(以前做symbian做神经了,啥都喜欢自己做)自己做委托,自己做控件,大家别说我贱哦。
画个圆角的矩形没啥难的,有两种方法:
1 。直接修改view的样式,系统提供好的了:
view.layer.cornerRadius = 6;
view.layer.masksToBounds = YES;
用layer做就可以了,十分简单。这个需要倒库QuartzCore.framework;
2. 在view 里面画圆角矩形
CGFloat radius = 20.0;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1);
CGFloat minx = CGRectGetMinX(rect), midx = CGRectGetMidX(rect), maxx = CGRectGetMaxX(rect);
CGFloat miny = CGRectGetMinY(rect), midy = CGRectGetMidY(rect), maxy = CGRectGetMaxY(rect);
CGContextMoveToPoint(context, minx, midy);
CGContextAddArcToPoint(context, minx, miny, midx, miny, radius);
CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius);
CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius);
CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
用画笔的方法,在drawRect里面做。
希望大家都不要满足现状,老用xib, 多思考,这样才不至于被淘汰。
UIView 进行各种动画展示及其用法解释
//第一种动画方式
- (void) first_animations
{
[UIViewbeginAnimations:nilcontext:nil];
//启动动画动作
[UIViewsetAnimationRepeatCount:1];//设置是否重复播放
[UIViewsetAnimationDuration:1];//设置动画持续时间
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseIn];//动画曲线,具体的应用
,可以经过实验检测
[UIViewsetAnimationDelegate:self];//动画块的某个方法(最下方),委托到本类的实例
[UIViewsetAnimationDidStopSelector:@selector(resetView)];//动画结束后去执行的方法
CGAffineTransformoneTransform =CGAffineTransformRotate(self.animatView.transform,
degreesToRadian(180));//进行 CGAffineTransform 方式的动作(旋转拉伸等等)===>(对于CGAffineTransform 可以另外开辟一个关于CGAffineTransform使用详情的文章进行专门介绍)
CGAffineTransformtwoTransform =CGAffineTransformTranslate(self.animatView.transform,0,-100);
CGAffineTransformnewTransform =CGAffineTransformConcat(oneTransform,
twoTransform);
[self.animatViewsetTransform:newTransform];
[UIViewcommitAnimations];//有些网友说,这是动画结束.起始经过本人尝试试验.其实应该是,执行上方定义的动画块内容.
}
//第二中动画定义方式
- (void) second_animations
{
CABasicAnimation*animation = [CABasicAnimationanimationWithKeyPath:@"opacity"];
[animationsetDuration:1];
[animationsetRepeatCount:0];
[animationsetAutoreverses:YES];//自动反向动画
[animationsetFromValue:[NSNumbernumberWithFloat:1.0]];
[animationsetToValue:[NSNumbernumberWithFloat:0]];
[animationsetDelegate:self];
[self.animatView.layeraddAnimation:animationforKey:@"firstView-Opacity"];
}
- (void) third_animations
{
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationRepeatCount:1];
[UIViewsetAnimationDuration:1];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseIn];
[UIViewsetAnimationTransition:UIViewAnimationTransitionFlipFromRightforView:self.containViewcache:YES];
[UIViewsetAnimationDidStopSelector:@selector(animationDidStop:finished:)];
[UIViewcommitAnimations];
}
- (void) fourth_animations
{
CATransition*transition = [CATransitionanimation];
transition.duration = 1.0f; /* 间隔时间*/
transition.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
/* 动画的开始与结束的快慢*/
transition.type = @"pageCurl"; //@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
transition.subtype =kCATransitionFromRight;
transition.removedOnCompletion =YES;
transition.fillMode =kCAFillModeBackwards;
transition.delegate = self;
[self.animatView.layeraddAnimation:transitionforKey:nil];
}
-(void) resetView
{
[self.animatViewsetTransform:CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180))];
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#pragma mark Delegate Methods
- (void)animationDidStop:(CAAnimation *) theAnimation finished:(BOOL) flag {
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#define degreesToRadian(x) (M_PI * (x) / 180.0)
================再次挖井的分割线07.11=============
分享到:
相关推荐
已封装好的实现渐变的UIView,只需传入渐变开始值和结束值就可直接使用。有四种渐变方向可选
自己写了一个Dome 实现了UIView或者时UIViewController 缩放动画效果
自定义 UIView的阴影效果自定义 UIView的阴影效果
UIView 震动动画效果 AFViewShaker ,AFViewShaker 是一个简单的工具用来执行 。 使用方法: AFViewShaker *...
Twinkle - ✨一个Swift和简单的方法能让任何UIView产生闪烁效果
UIView切换效果集 HMGLTransitions ,HMGLTransitions 实现了一组不同的 UIView 之间切换效果的功能。
6个UIView的弹簧效果布局,添加点击实现
uiView 动画翻转的效果,显示前后两个视图替换显示
支持 CocoaPods! pod 'LCBlur' GitHub:https://github.com/iTofu/LCBlur 请在 GitHub 上查阅,以保证版本最新! 有问题请移步 GitHub!...(之前发过一次,效果没讲清楚,貌似不能编辑,重新发下哈!)
为UIView添加弹簧效果,并设置显示文本内容和弹出次数
该类继承UIView,展示一个跑马灯效果的View,使用就像普通UIView一样简单,通过改变几个属性控制颜色、速度等。
Fireworks - 为 UIView 添加烟花动画效果
该源码案例是一款一个内置波浪动画的UIView效果,源码KYWaterWaveView,这种效果也是我们在游戏中经常使用的跳跃或者水波的动画效果,希望这个案例能够帮到大家的学习。
使用拓展与runtime,为UIView添加手势事件
ShadowView 让你能够轻松在UIView上实现阴影效果
SnapTimer:定制 UIView 模仿 Snapchat's stories 定时器效果
本文主要介绍 Swift UIView,这里给大家提供代码示例作为参考为UIView 添加点击事件和点击效果,希望能帮助IOS开发的同学
将闪光效果应用于iOS应用程序的任何视图及其子视图的超级简单方法。要求iOS 10以上安装可可豆UIView-Shimmer可通过。 要安装它,只需将以下行添加到您的Podfile中: pod 'UIView-Shimmer' , '~> 1.0' 然后导入 ...
使用Swfit扩展为UIView添加随UIScrollView滚动产生视差效果