【代码笔记】iOS-淡出淡入效果
2024-08-29 14:56:50
一,效果图。
二,工程图。
三,代码.
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.
}
最新文章
- 【leetcode】Binary Tree Zigzag Level Order Traversal
- 改造一下C# Substring()函数
- Asp.Net之后台加载JS和CSS
- 倍增法lca
- android style 中一些颜色的定义
- STM32 常用GPIO操作函数记录
- Find mac address
- ntpServer搭建用以进行时间同步
- 最近的两个小项目,2:Python webapp的docker镜像
- c 中关于int,unsigned int , short 各种类型总结
- 【js】基本类型和引用类型的区别
- K8S集群技术
- if语句与switch语句
- MongoDB 在 windows 下的安装与服务配置
- hibernate--DetachedCriteria(离线条件查询)
- Linux正则与文本处理工具(10)
- 向Sql Server数据库插入中文时显示乱码的解决办法 (转)
- Python3 itchat微信获取好友、公众号、群聊的基础信息
- [csp-201809-4]再卖菜 差分约束or记忆化搜索
- log4j2按日志级别输出到指定文件
热门文章
- 用Android模拟器也可以开发和测试NFC应用
- 再谈ABC
- Bootstrap学习笔记系列3-------Bootstrap简单表单显示
- printf的题目
- mysql-databaseython 3.4.0 with MySQL database
- Scalaz(15)- Monad:依赖注入-Reader besides Cake
- php中的常用数组函数(八) 排序函数汇总(sort、rsort、usort、asort、uasort、arsort、ksort、uksort、krsort、natsort、natcasesort、array_multisort)
- 【Asphyre引擎】冒险岛换装Demo升级到最新版PXL
- CGI与Servlet的比较
- Android开发跳槽、简历和面试的那些事