一,效果图。

二,工程图。

三,代码.

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@end

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. //UIView
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(10, 100, 200, 200)];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view]; //淡出
//[self fadeOut:view]; //淡入
//[self fadeIn:view]; } //淡出
-(void) fadeOut:(UIView *)view
{
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];
[view setAlpha:0.0f];
[UIView commitAnimations];
} //淡入
-(void) fadeIn:(UIView *)view
{
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];
[view setAlpha:1.0f];
[UIView commitAnimations];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
 
 

【代码笔记】iOS-淡出淡入效果的更多相关文章

  1. C# 窗体淡出淡入效果

    [DllImport("user32.dll")]        //设置控件出现动画        private static extern bool AnimateWindo ...

  2. 【代码笔记】iOS-翻书效果的实现

    代码: RootViewController.m #import "RootViewController.h" @interface RootViewController () @ ...

  3. 【代码笔记】iOS-抽屉效果的实现

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  4. 【代码笔记】iOS-水波效果

    一,效果图. 二,工程图. 三,代码. ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIVie ...

  5. 【代码笔记】iOS-翻页效果的实现

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  6. 【代码笔记】iOS-侧滑效果

    一,效果图. 二,工程图. 三,代码. AppDelegate.h #import <UIKit/UIKit.h> //加入头文件 #import "PPRevealSideVi ...

  7. 利用CSS3制作淡入淡出动画效果

    CSS3新增动画属性“@-webkit-keyframes”,从字面就可以看出其含义——关键帧,这与Flash中的含义一致. 利用CSS3制作动画效果其原理与Flash一样,我们需要定义关键帧处的状态 ...

  8. 练习:javascript淡入淡出半透明效果

    划过无透明 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  9. Jquery制作--焦点图淡出淡入

    之前写了一个焦点图左右轮播的,感觉淡出淡入用得也比较多,就干脆一起放上来啦.这个容器用了百分比宽度,图片始终保持居中处理,定宽或者自适应宽度都是可以的. 兼容到IE6+以上浏览器,有淡出淡入速度和切换 ...

  10. iOS各种动画效果

    ios各种动画效果 最普通动画: //开始动画 [UIView beginAnimations:nil context:nil];  //设定动画持续时间 [UIView setAnimationDu ...

随机推荐

  1. 【转载】ASP.NET MVC Web API 学习笔记---第一个Web API程序

    1. Web API简单说明 近来很多大型的平台都公开了Web API.比如百度地图 Web API,做过地图相关的人都熟悉.公开服务这种方式可以使它易于与各种各样的设备和客户端平台集成功能,以及通过 ...

  2. ASP.NET MVC文章附加有源码下载的文章

    很多一段时间以来,Insus.NET有分享很多有关ASP.NET MVC的文章,每隔一段时间,会把源码以及数据库分享供大家下载. 你可以按时间排序,文章越新,源码以及数据数据也就越新. 你可以从下面的 ...

  3. winform自定义日期控件,要求可以手动输入日期DatePicker

    要求:文本框中能手动输入数字,向上箭头根据鼠标位置给年月日递增,向下箭头递减 一:页面加载时: private void FlatDatePicker_Load(object sender, Even ...

  4. Win10 QQ五笔默认中文,InputMode默认中文

    Win10系统安装了QQ五笔后,InputMode默认英文,必须用鼠标点或者按 Ctrl+空格才能转换为中文.非常不方便. 即使将微软拼音默认为中文也不管用,解决方法如下: 设置后,无论你打开运行.记 ...

  5. DataTable 除去列中重复值

    DataTable dtPCI = dtblSourceData.DefaultView.ToTable(true, new string[] { "Server Cell PCI" ...

  6. RARP反向地址转换协议

    反向地址转换协议(RARP:Reverse Address Resolution Protocol) 反向地址转换协议(RARP)允许局域网的物理机器从网关服务器的 ARP 表或者缓存上请求其 IP ...

  7. 2016 大连网赛---Function(单调栈)

    题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=5875 Problem Description The shorter, the simpl ...

  8. uums

    http://blog.csdn.net/hudon/article/details/1506042 http://www.cnblogs.com/biakia/p/4779655.html http ...

  9. Java基础复习笔记系列 五 常用类

    Java基础复习笔记系列之 常用类 1.String类介绍. 首先看类所属的包:java.lang.String类. 再看它的构造方法: 2. String s1 = “hello”: String ...

  10. Scalaz(0) - 写在前面

    面向对象编程范畴(OOP)从80年代C++到90年代java的兴起已经经历了几十年的高潮,是不是已经发展到了尽头,该是函数式编程(FP)开始兴旺发达的时候了吧.这样说似乎心眼儿有点坏,可能会得罪当今大 ...