UIView和Masonry实现动画效果
Masonry 实现动画效果如下:
//button点击方法
- (void)clickedButton
{
static BOOL isMove; //默认是NO
Weakify(weakSelf); //告诉self.view约束需要更新
[weakSelf.view setNeedsUpdateConstraints];
//调用此方法告诉self.view检测是否需要更新约束,若需要则更新,下面添加动画效果才起作用
[weakSelf.view updateConstraintsIfNeeded]; if (isMove) { isMove = NO;
//添加动画
[UIView animateWithDuration: animations:^{
[weakSelf.displayView mas_updateConstraints:^(MASConstraintMaker *make) {
//更改距顶上的高度
make.top.equalTo(weakSelf.baseView.mas_bottom).with.offset();
}]; //必须调用此方法,才能出动画效果
[weakSelf.view layoutIfNeeded];
}];
}
else{ isMove = YES;
//添加动画
[UIView animateWithDuration: animations:^{ [weakSelf.displayView mas_updateConstraints:^(MASConstraintMaker *make) {
//更改距顶上的高度
make.top.equalTo(weakSelf.baseView.mas_bottom).with.offset(-);
}];
//必须调用此方法,才能出动画效果
[weakSelf.view layoutIfNeeded];
}];
}
}
重点说明:
UIView和Masonry实现动画效果的更多相关文章
- 实现多个UIView之间切换的动画效果
@interface RootViewController (){ UIView *view1; UIView *view2; int flag; } @end @implementation Roo ...
- UIView动画效果
做出UI界面,实现程序功能,是重中之重,但是通过动画提升使用体验,一般人应该不会拒绝吧. 那么问题又来了,怎么做? 一: 稳扎稳打: 一步一步来吧,毕竟,心急吃不了热豆腐. 1.开启一个动画 2,设置 ...
- 自定义UIView动画效果
最普通动画: //开始动画 [UIView beginAnimations:nil context:nil]; //设定动画持续时间 [UIView setAnimationDuration:]; / ...
- IOS开发-UIView之动画效果的实现方法(合集)
http://www.cnblogs.com/GarveyCalvin/p/4193963.html 前言:在开发APP中,我们会经常使用到动画效果.使用动画可以让我们的APP更酷更炫,最重要的是优化 ...
- UIView动画效果之----翻转.旋转.偏移.翻页.缩放.取反的动画效
翻转的动画 //开始动画 [UIView beginAnimations:@"doflip" context:nil]; //设置时常 [UIView setAnimationDu ...
- iOS UIView动画效果 学习笔记
//启动页动画 UIImageView *launchScreen = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; ...
- Masonry整体动画更新约束
前言 说到iOS自动布局,有很多的解决办法.有的人使用xib/storyboard自动布局,也有人使用frame来适配.对于前者,笔者并不喜欢,也不支持.对于后者,更是麻烦,到处计算高度.宽度等,千万 ...
- iOS动画效果和实现
动画效果提供了状态或页面转换时流畅的用户体验,在iOS系统中,咱们不需要自己编写绘制动画的代码,Core Animation提供了丰富的api来实现你需要的动画效果. UIKit只用UIView来展示 ...
- tableView简单的动画效果
tableView 中一些动画效果通常都是实现willDisplayCell的方法来展示出一些动画的效果 (1).带有3D效果的小型动态展示 -(void)tableView:(UITableView ...
随机推荐
- 如何用Adb连接Android手机 & unable to connect to 192.168.1.100:5555的原因和解决方法
利用adb来连接手机, 有两种方式: 1, wifi 2, usb. 1. 通过wifi, 利用adb来连接手机. 在pc的cmd中输入命令: adb connect 192.168.1.100 其中 ...
- 查看Ubuntu的版本
方法一: cat /etc/issue 方法二: lsb_release -a
- POJ3211(trie+01背包)
Washing Clothes Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 9384 Accepted: 2997 ...
- 【旧文章搬运】PsVoid中IrpCreateFile函数在Win7下蓝屏BUG分析及解决
原文发表于百度空间,2010-04-05========================================================================== 这也许是我 ...
- Windows下安装zip包解压版mysql
Windows下安装zip包解压版mysql 虽然官方提供了非常好的安装文件,但是有的时候不想每次再重装系统之后都要安装一遍MySQL,需要使用zip包版本的MySQL.在安装时需如下三步: 1. 新 ...
- [转载] C++ 类中的类成员变量怎么调用带参数的构造函数来初始化?
#include "stdafx.h" class A { public: A(){ax = ;}; A(int a){ax = a;}; int ax; }; class B { ...
- 4-3逻辑非运算符及案例 & 4-4
创建类 LoginDemo3 这里取反 !(n%3==0) package com.imooc.operator; import java.util.Scanner; public class Log ...
- ssl 证书申请
https(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的 http 通道,简单讲是 http 的安全版.即 ht ...
- POJ3264 【RMQ基础题—ST-线段树】
ST算法Code: //#include<bits/stdc++.h> #include<cstdio> #include<math.h> #include< ...
- luoguP3796[模板]AC自动机(加强版)
传送门 ac自动机模板,可能我写的ac自动机是有点问题的,所以跑的有些慢 暴力跳fail统计 代码: #include<cstdio> #include<iostream> # ...