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 ...
随机推荐
- LINQ 查询表达式(C# 编程指南)
语言集成查询 (LINQ) 是一组技术的名称,这些技术建立在将查询功能直接集成到 C# 语言(以及 Visual Basic 和可能的任何其他 .NET 语言)的基础上. 借助于 LINQ,查询现在 ...
- [MetaHook] Surface hook
Hook ISurface function. #include <metahook.h> #include <vgui/ISurface.h> using namespace ...
- Laravel 安装多国语言包后,phpstorm 还是报错
问题: 解决办法: vagrant@homestead:~/Code/awbeci$ composer require "overtrue/laravel-lang:~3.0" 总 ...
- CSS 颜色代码大全
CSS颜色: 转载:http://www.cnblogs.com/axing/archive/2011/04/09/CSS.html
- name after, name for, name as
name after, name for, name as name after是一个常见用法 : 1.Her parents named her Sophia after her grandmo ...
- [转]mysql免安装版配置
现在mysql有一个installer,相当于安装包管理器.包含mysql的各个组件,比如workbench,各个语言的connector.十分方便,不用就可惜了.实在没有必要下载zip版,自己配置. ...
- Linux下sysstat工具学习
Linux下,我们多用ssh链接服务器远程操控.对于系统的监控必不可少,sysstat很不错的监控工具包. sysstat官网:http://sebastien.godard.pagesperso-o ...
- window配置nginx+php+mysql
博客来源: http://www.cnblogs.com/wuzhenbo/p/3493518.html 启用nginx D:\nginx>nginx.exe 重启 D:\nginx> ...
- 创建mysql 存储过程
CREATE PROCEDURE `test_insert_stu`() BEGIN DECLARE num INT; SET num = 0; WHILE (num<10) DO insert ...
- iOS开发:读取pdf文件
方法一:使用QLPreviewController #pragma mark 浏览存在沙盒的文件 -(void)quickLook { QLPreviewController *QLPreviewV ...