iOS Swift最简单的Animation
最近发现Animation是一个iOS开发中非常好玩的元素,能给应用的交互性增色不少。比如很多音乐应用的菜单从底部弹出和隐藏的效果。
Animation最核心的当然就是UIView的animateWithDuration这个类方法了,另外有个博客介绍了很多animation的文章也很不错:
http://www.devtalking.com/articles/uiview-animation-practice/
念在好久没用swift开发了,于是花了几分钟写了个简单的demo复习下
//
// ViewController.swift
// UIAnimationTest
//
// Created by shen on 15/10/24.
// Copyright © 2015年 shen. All rights reserved.
// import UIKit class ViewController: UIViewController { var popView:UIView!
var clkbtn:UIButton!=UIButton()
var display:Bool=false override func viewDidLoad() {
super.viewDidLoad()
popView=UIView();
popView.frame=CGRectMake(,self.view.frame.size.height, self.view.frame.size.width, );
popView.backgroundColor=UIColor.redColor();
self.view.addSubview(popView); clkbtn=UIButton();
clkbtn.frame=CGRectMake(self.view.frame.size.width/-, self.view.frame.size.height/-, , );
clkbtn.setTitle("弹出", forState: UIControlState.Normal);
clkbtn.backgroundColor=UIColor.grayColor();
clkbtn.addTarget(self, action: "buttonClicked:", forControlEvents: UIControlEvents.TouchUpInside);
self.view.addSubview(clkbtn); } override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
} func buttonClicked(sender:UIButton)
{
if(display==false){
display=true;
clkbtn.setTitle("隐藏", forState: UIControlState.Normal);
UIView.animateWithDuration(0.5, animations: {
self.popView.frame=CGRectMake(,self.view.frame.size.height-, self.view.frame.size.width, );
}, completion: nil);
}else{
display=false;
clkbtn.setTitle("弹出", forState: UIControlState.Normal);
UIView.animateWithDuration(0.5, animations: {
self.popView.frame=CGRectMake(,self.view.frame.size.height, self.view.frame.size.width, );
}, completion: nil);
}
}
}

demo地址: https://github.com/rayshen/SwiftAnimationTest
iOS Swift最简单的Animation的更多相关文章
- ios swift 实现简单MVP模式
在移动开发中,会用到各种架构,比如mvp,mvvm等,其目的就是为了让项目代码的可读性更好,减轻在android(activity) ios(controller)中的大量代码问题.接下来就开始我们的 ...
- iOS开发Swift篇—简单介绍
iOS开发Swift篇—简单介绍 一.简介 Swift是苹果于2014年WWDC(苹果开发者大会)发布的全新编程语言 Swift在天朝译为“雨燕”,是它的LOGO 是一只燕子,跟Objective-C ...
- ios swift 实现饼状图进度条,swift环形进度条
ios swift 实现饼状图进度条 // // ProgressControl.swift // L02MyProgressControl // // Created by plter on 7/2 ...
- 如何使用 Swift 开发简单的条形码检测器?
[编者按]本文作者为 Matthew Maher,主要手把手地介绍如何用 Swift 构建简单的条形码检测器.文章系 OneAPM 工程师编译整理. 超市收银员对货物进行扫码,机场内录入行李或检查乘客 ...
- ios下最简单的正则,RegexKitLite
ios下最简单的正则,RegexKitLite 1.去RegexKitLite下载类库,解压出来会有一个例子包及2个文件,其实用到的就这2个文件,添加到工程中.备用地址:http://www.coco ...
- iOS中XMPP简单聊天实现 好友和聊天
版权声明本文由陈怀哲首发自简书:http://www.jianshu.com/users/9f2e536b78fd/latest_articles;微信公众号:陈怀哲(chenhuaizhe2016) ...
- iOS swift的xcworkspace多项目管理(架构思想)
iOS swift的xcworkspace多项目管理(架构思想) 技术说明: 今天在这里分享 swift下的 xcworkspace多项目管理(架构思想),能为我们在开发中带来哪些便捷?能为我们对整 ...
- iOS Swift 模块练习/swift基础学习
SWIFT项目练习 SWIFT项目练习2 iOS Swift基础知识代码 推荐:Swift学习使用知识代码软件 0.swift中的宏定义(使用方法代替宏) 一.视图 +控件 1.UIImag ...
- Building gRPC Client iOS Swift Note Taking App
gRPC is an universal remote procedure call framework developed by Google that has been gaining inter ...
随机推荐
- 全球第一本基于Bootstrap V3.x的图书《深入理解Bootstrap》终于上市了,再次免费送书15本【活动结束】
先说活动规则,再说书的事 经过将近1年的努力,终于有了第一本自己独立编写的书:<深入理解Bootstrap>,基于最新版V 3.1 ,侧重于源码详解.架构分析.插件扩展(全新开发)实战.为 ...
- Bink Player
class CBIKMaterial { public: CBIKMaterial(); ~CBIKMaterial(); bool Init(const char *pFileName); void ...
- devexpress xtrareport 并列绑定两个数据源,如何实现?
如下图,要在xtrareport 并列绑定两个不同的数据源datatable1和datatable 2,并且table1中的只有10行数据,table2中有20行数据,如何实现
- 【位运算经典应用】 N皇后问题
说到位运算的经典应用,不得不说N皇后问题. 学过程序设计的都知道N皇后问题,没听过也没关系.很简单,最传统的的N皇后问题是这个样子的,给你一个n * n大小的board,让你放n个皇后(国际象棋),要 ...
- Javascript中的循环变量声明,到底应该放在哪儿?
相信很多Javascript开发者都在声明循环变量时犹豫过var i到底应该放在哪里:放在不同的位置会对程序的运行产生怎样的影响?哪一种方式符合Javascript的语言规范?哪一种方式和ecma标准 ...
- Android子线程真的不能更新UI么
Android单线程模型是这样描述的: Android UI操作并不是线程安全的,并且这些操作必须在UI线程执行 如果在其它线程访问UI线程,Android提供了以下的方式: Activity.run ...
- python 2.7 和3.0input区别
name = raw_input('请输入用户名:')#python2.7的用法 name = input('请输入用户名:')#python3.0的用法 print(name)
- window配置nginx+php+mysql
博客来源: http://www.cnblogs.com/wuzhenbo/p/3493518.html 启用nginx D:\nginx>nginx.exe 重启 D:\nginx> ...
- 【日常笔记】datatables表格数据渲染
现在有很多表格渲染方式 这里只是记录怎么使用datatables渲染数据 使用datatables可以更方便的来渲染数据 [中文api]http://datatables.club/index.htm ...
- python之旅3
1 collections系列 方法如下 class Counter(dict): '''Dict subclass for counting hashable items. Sometimes ca ...