一,效果图。

二,工程图。

三,代码.

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.
}
 
 

最新文章

  1. 【leetcode】Binary Tree Zigzag Level Order Traversal
  2. 改造一下C# Substring()函数
  3. Asp.Net之后台加载JS和CSS
  4. 倍增法lca
  5. android style 中一些颜色的定义
  6. STM32 常用GPIO操作函数记录
  7. Find mac address
  8. ntpServer搭建用以进行时间同步
  9. 最近的两个小项目,2:Python webapp的docker镜像
  10. c 中关于int,unsigned int , short 各种类型总结
  11. 【js】基本类型和引用类型的区别
  12. K8S集群技术
  13. if语句与switch语句
  14. MongoDB 在 windows 下的安装与服务配置
  15. hibernate--DetachedCriteria(离线条件查询)
  16. Linux正则与文本处理工具(10)
  17. 向Sql Server数据库插入中文时显示乱码的解决办法 (转)
  18. Python3 itchat微信获取好友、公众号、群聊的基础信息
  19. [csp-201809-4]再卖菜 差分约束or记忆化搜索
  20. log4j2按日志级别输出到指定文件

热门文章

  1. 用Android模拟器也可以开发和测试NFC应用
  2. 再谈ABC
  3. Bootstrap学习笔记系列3-------Bootstrap简单表单显示
  4. printf的题目
  5. mysql-databaseython 3.4.0 with MySQL database
  6. Scalaz(15)- Monad:依赖注入-Reader besides Cake
  7. php中的常用数组函数(八) 排序函数汇总(sort、rsort、usort、asort、uasort、arsort、ksort、uksort、krsort、natsort、natcasesort、array_multisort)
  8. 【Asphyre引擎】冒险岛换装Demo升级到最新版PXL
  9. CGI与Servlet的比较
  10. Android开发跳槽、简历和面试的那些事