UIView 等会效果简单实现,哪一个登录页面的demo来举例子吧.

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;

UIView的一个类方法,可以看出这个方法里面只有两个参数:

duration: 动画持续时间;

animations:动画闭包,在这个闭包中你可以改变UIView的各种动画属性(这个方法中可以同时改变多个属性);

// 闭包里面是textField最终出现的位置,前提是你已经设置好了textField的位置.
[UIView animateWithDuration:0.5 animations:^{
self.emailTextField.frame = CGRectMake(, self.userImg.frame.origin.y + self.userImg.bounds.size.height + , screen_width - , );
self.pwdTextField.frame = CGRectMake(, self.emailTextField.frame.origin.y + self.emailTextField.bounds.size.height, screen_width - , ); } completion:nil];

这个就是上面的代码动画出现的过程截图,emailText 和 pwdTextField 分别重两次移动到中间位置;

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion;

这个方法多了几个参数:

delay:延时时间;

options:动画效果,比如重复动画、前后运动等;

[UIView animateWithDuration:0.5 delay: options:UIViewAnimationOptionCurveEaseInOut  animations:^{
self.emailTextField.frame = CGRectMake(, self.userImg.frame.origin.y + self.userImg.bounds.size.height + , screen_width - , );
} completion:nil];
CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI);
[UIView animateWithDuration:0.5 delay:0.3 options:UIViewAnimationOptionCurveLinear animations:^{
self.pwdTextField.frame = CGRectMake(, self.emailTextField.frame.origin.y + self.emailTextField.bounds.size.height, screen_width - , );
self.userImg.transform = rotation;
} completion:nil];

这个过程里有头像的转动,emailText 和 pwdTextField 分别重两次移动到中间位置;

这两个添加动画效果的方法的代码附在下面:

//
// ViewController.m
// loginDemo20160330
//
// Created by miaoguodong on 16/3/30.
// Copyright © 2016年 miaoguodong. All rights reserved.
// #import "ViewController.h"
#define screen_width ([UIScreen mainScreen].bounds.size.width)
#define screen_height ([UIScreen mainScreen].bounds.size.height)
@interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *loginBgImg;
@property (weak, nonatomic) IBOutlet UIImageView *userImg; @property (weak, nonatomic) IBOutlet UITextField *emailTextField;
@property (weak, nonatomic) IBOutlet UITextField *pwdTextField; @end @implementation ViewController
- (void)dealloc
{
self.loginBgImg = nil;
self.userImg = nil;
self.emailTextField = nil;
self.pwdTextField = nil;
} - (void)viewDidLoad {
[super viewDidLoad]; self.loginBgImg.frame = CGRectMake(, , screen_width, screen_height);
self.loginBgImg.image = [UIImage imageNamed:@"BgImage"]; self.userImg.frame = CGRectMake((self.loginBgImg.bounds.size.width - )/, , , );
self.userImg.image = [UIImage imageNamed:@"usrIcon"]; self.emailTextField.frame = CGRectMake(screen_width, self.userImg.frame.origin.y + self.userImg.bounds.size.height + , screen_width - , );
self.pwdTextField.frame = CGRectMake(-screen_width, self.emailTextField.frame.origin.y + self.emailTextField.bounds.size.height, screen_width - , );
// self.emailTextField.frame = CGRectMake(30, self.userImg.frame.origin.y + self.userImg.bounds.size.height, screen_width - 60, 40);
// self.pwdTextField.frame = CGRectMake(30, self.emailTextField.frame.origin.y + self.emailTextField.bounds.size.height, screen_width - 60, 40); UIView *emailLeftView = [[UIView alloc]initWithFrame:CGRectMake(, , self.emailTextField.bounds.size.height, self.emailTextField.bounds.size.height)];
UIImageView *eleftImg = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
eleftImg.image = [UIImage imageNamed:@"user"];
[emailLeftView addSubview:eleftImg];
self.emailTextField.leftView = emailLeftView;
self.emailTextField.leftViewMode = UITextFieldViewModeAlways; UIView *pwdLeftView = [[UIView alloc]initWithFrame:CGRectMake(, , self.pwdTextField.bounds.size.height, self.pwdTextField.bounds.size.height)];
UIImageView *pleftImg = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
pleftImg.image = [UIImage imageNamed:@"pwd"];
[pwdLeftView addSubview:pleftImg];
self.pwdTextField.leftView = pwdLeftView;
self.pwdTextField.leftViewMode = UITextFieldViewModeAlways; // 简单设置 text输入框出现 // [UIView animateWithDuration:0.5 animations:^{
// self.emailTextField.frame = CGRectMake(30, self.userImg.frame.origin.y + self.userImg.bounds.size.height + 30, screen_width - 60, 40);
// self.pwdTextField.frame = CGRectMake(30, self.emailTextField.frame.origin.y + self.emailTextField.bounds.size.height, screen_width - 60, 40);
//
// } completion:nil]; // 设置 text输入框有动画效果的飞入
[UIView animateWithDuration:0.5 delay: options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.emailTextField.frame = CGRectMake(, self.userImg.frame.origin.y + self.userImg.bounds.size.height + , screen_width - , );
} completion:nil];
CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI);
[UIView animateWithDuration:0.5 delay:0.3 options:UIViewAnimationOptionCurveLinear animations:^{
self.pwdTextField.frame = CGRectMake(, self.emailTextField.frame.origin.y + self.emailTextField.bounds.size.height, screen_width - , );
self.userImg.transform = rotation;
} completion:nil]; // Do any additional setup after loading the view, typically from a nib.
} - (void)viewWillAppear:(BOOL)animated
{ } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

iOS UIView 动画浅谈的更多相关文章

  1. iOS 自定义转场动画浅谈

    代码地址如下:http://www.demodashi.com/demo/11612.html 路漫漫其修远兮,吾将上下而求索 前记 想研究自定义转场动画很久了,时间就像海绵,挤一挤还是有的,花了差不 ...

  2. iOS开发之浅谈MVVM的架构设计与团队协作

    今天写这篇博客是想达到抛砖引玉的作用,想与大家交流一下思想,相互学习,博文中有不足之处还望大家批评指正.本篇博客的内容沿袭以往博客的风格,也是以干货为主,偶尔扯扯咸蛋(哈哈~不好好工作又开始发表博客啦 ...

  3. iOS应用架构浅谈

    (整理至http://www.cocoachina.com/ios/20150414/11557.html) 缘由 从事iOS工作一年多了,主要从事QQ钱包SDK开发和财付通app维护,随着对业务的慢 ...

  4. iOS - UIView 动画

    1.UIView 动画 核心动画 和 UIView 动画 的区别: 核心动画一切都是假象,并不会真实的改变图层的属性值,如果以后做动画的时候,不需要与用户交互,通常用核心动画(转场). UIView ...

  5. iOS UIView动画效果 学习笔记

    //启动页动画 UIImageView *launchScreen = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; ...

  6. IOS UIView动画(封装动画)

    ● UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView 将为这些改变提供动画支持 ● 执行动画所需要的工作由UIView类自动完成,但仍要在希望执行动画时通知视 图, ...

  7. iOS 应用架构浅谈

    当我们讨论客户端应用架构的时候,我们在讨论什么? 其实市面上大部分应用不外乎就是颠过来倒过去地做以下这些事情: 简单来说就是调API,展示页面,然后跳转到别的地方再调API,再展示页面. App确实就 ...

  8. iOS之多线程浅谈

    1)并发和并行的区别 在软件开发中不可避免的会遇到多线程的问题,在iOS客户端开发(或者.NET的winform或者wpf这样的cs程序)中就更不可避免的会用到多线程,在bs类型的web项目中要考虑一 ...

  9. iOS之RunTime浅谈

    首先说一下什么是runtime:RunTime简称运行时.就是系统在运行的时候的一些机制,其中最主要的是消息机制.对于C语言,函数的调用 在编译的时候会决定调用哪个函数( C语言的函数调用请看这里 ) ...

随机推荐

  1. 一些特殊的URI编码字符

    字符 URL编码值 space %20 " %22 # %23 % %25 & %26 ( %28 ) %29 + %2B , %2C / %2F : %3A ; %3B < ...

  2. Android Activity的加载的模式

    ---恢复内容开始--- 本文来自http://www.cnblogs.com/lwbqqyumidi/p/3771542.html launchMode在多个Activity跳转的过程中扮演着重要的 ...

  3. .net 根据银行卡获取银行信息

    using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary ...

  4. BZOJ 1923: [Sdoi2010]外星千足虫

    Description 给出几个异或方程组求解,\(n \leqslant 2000\) Sol 高斯消元. 直接消元就行,遇到自由元就直接输出,同时记录一下用到的最高行数. 复杂度不科学就可以用 b ...

  5. HDU 5102 The K-th Distance(模拟)

    题意:输入一棵树,输出前k小的点对最短距离dis(i,j)的和. 模拟,官方题解说得很清楚了.不重复了. http://bestcoder.hdu.edu.cn/ 需要注意的是,复杂度要O(n+k), ...

  6. 17. Letter Combinations of a Phone Number

    题目: Given a digit string, return all possible letter combinations that the number could represent. A ...

  7. ios build时,Undefined symbols for architecture xxx问题的总结

    简单来说,Undefined symbols基本上等于JAVA的ClassNotFoundException,最常见的原因有这几种: build的时候没有加framework 比如说,有一段代码我用了 ...

  8. TCP与UDP的区别

    TCP与UDP的区别 TCP面向连接:UDP是无连接,即发送数据之前不需要建立连接 TCP提供可靠的服务,TCP连接传送的数据,无差错.不丢失.不重复,且按顺序到达:UDP尽最大努力交付,即不保证可靠 ...

  9. libqrencode生成二维码

    在生成二维码的库中QREncoder最为常见,但是由于中文字符的特殊性,生成中文的时候会出现一定的错误,所以博主改用libqrencode,是一个纯C编写的类库,支持面也更广泛. ① 下载libqre ...

  10. C++ 基础知识复习(五)

    UML建模部分 70. 什么是UML: 答: Unified Modeling Language, 统一建模语言,是一种标准的图形化建模语言.是面向对象分析和设计的标准表示. 71. UML有哪些图: ...