AYVibrantButton

https://github.com/a1anyip/AYVibrantButton

AYVibrantButton is a stylish button with iOS 8 vibrancy effect. It is a subclass of UIButton that has a simple yet elegant appearance and built-in support for UIVisualEffectView and UIVibrancyEffect classes introduced in iOS 8. Yet, it can be used on iOS 7 without the vibrancy effect.

AYVibrantButton是一个具有 iOS 8 模糊背景效果的按钮.他继承自 UIButton, 有一个很漂亮的样式, 内置了 iOS8 中新出的 UIVisualEffectView 与 UIVibrancyEffect .当然, 你也可以用在 iOS7 上, 只是没有模糊背景效果而已.

Configurations

Vibrant buttons can be configured with one of the three supported button styles, inverttranslucentand fill (see examples below).

该按钮可以配置3种样式.

Some basic properties like icontextfontalphacorner radiusborder width and background color (for no vibrancy effect) can all be changed easily.

所有的基本属性,如图片, 文本, 字体, 透明度, 圆角, 以及边缘线条宽度以及背景色等等属性, 都可以进行修改.

The default vibrancy effect is for blur effect UIBlurEffectStyleLight. It could be set to anyUIVibrancyEffect instance. For today extensions, it should be set to [UIVibrancyEffect notificationCenterVibrancyEffect].

默认的模糊效果是 UIBlurEffectStyleLight , 他可以用来设置任何的 anyUIVibrancyEffect 对象. 现在已经对其进行了很多扩展, 支持 [UIVibrancyEffect notificationCenterVibrancyEffect] .

Note

Though vibrant buttons can be placed anywhere, it is recommended that vibrant buttons with vibrancy effects should be placed in the contentView of UIVisualEffectView (except in today view).

UIVisualEffectView can be created as follows.

虽然这个按钮可以放置在任何地方, 但是呢, 我还是推荐将其放置在 UIVisualEffectView 的 contentView 里面.

UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]];
effectView.frame = self.view.bounds;
[self.view addSubview:effectView];

Installation

CocoaPods

Add the following line to the Podfile.

你可以用 pod "AYVibrantButton" 来进行安装.

pod "AYVibrantButton"

Manual Installation

Simply add AYVibrantButton.h and AYVibrantButton.m to your project.

直接将 AYVibrantButton.h 与 AYVibrantButton.m 拖到你的项目中去即可.

Examples

The following images show the normal and highlighted (being pressed) button appearances.

以下例子演示了正常状态与高亮状态中的按钮的样式.

Invert style with vibrancy effect

AYVibrantButton *invertButton = [[AYVibrantButton alloc] initWithFrame:CGRectZero style:AYVibrantButtonStyleInvert];
invertButton.vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]];
invertButton.text = @"Invert";
invertButton.font = [UIFont systemFontOfSize:18.0];
[effectView.contentView addSubview:invertButton];

Translucent style with vibrancy effect

 

AYVibrantButton *translucentButton = [[AYVibrantButton alloc] initWithFrame:CGRectZero style:AYVibrantButtonStyleTranslucent];
translucentButton.vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]];
translucentButton.text = @"Translucent";
translucentButton.font = [UIFont systemFontOfSize:18.0];
[effectView.contentView addSubview:translucentButton];

Translucent style without vibrancy effect

 

Changelog

1.0.3

  • Added a new button style AYVibrantButtonStyleFill
  • Fixed an issue that setting button alpha removes the vibrancy effect

1.0.2

  • Support setting icon image

Creator

Alan Yip

License

The MIT License (MIT)

Copyright (c) 2014 Alan Yip

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

[翻译] AYVibrantButton的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. android学习-进程/线程管理-完整

    我们知道,应用程序的主入口都是main函数--"它是一切事物的起源" main函数工作也是千篇一律的, 初始化 比如ui的初始化,向系统申请资源等. 进入死循环 再循环中处理各种事 ...

  2. Linux-(kill,wc,killall,ln,cal,date)

    kill命令 1.命令格式: kill [参数] [进程号] 2.命令功能: 发送指定的信号到相应进程.不指定型号将发送SIGTERM(15)终止指定进程.如果仍无法终止该程序可用“-KILL” 参数 ...

  3. mysql查看权限的命令

    mysql查看用户权限的命令 1.这里用来查看用户存储过程: show grants for 用户; eg: show grants for root@'localhost';#这样就会把root用户 ...

  4. 用java做操作系统内核:软盘读写

    在前两节,我们将一段代码通过软盘加载到了系统内存中,并指示cpu执行加入到内存的代码,事实上,操作系统内核加载也是这么做的.只不过我们加载的代码,最大只能512 byte, 一个操作系统内核,少说也要 ...

  5. 说说java

    先说什么是java java是一种面向对象语言,真正的面向对象,任何函数和变量都以类(class)封装起来 至于什么是对象什么是类,我就不废话了 关于这两个概念的解释任何一本面向对象语言的教材里面都有 ...

  6. JS事件细分

    鼠标相关事件执行顺序 与 onmousedown 事件相关连得事件发生次序( 鼠标左侧/中间 按钮): onmousedown onmouseup onclick 与 onmousedown 事件相关 ...

  7. PHP 集成开发环境比较

    专注了这么些年技术,没有养成记录和积累的习惯.如今乐于开源和分享经验,却停笔踌躇,不知该从何处说起.开通博客也有一段时间了,也没能写出一篇像样的文章,其实这篇文章也是被我拉壮丁似的用来练手的.思前想后 ...

  8. vue权限路由实现方式总结二

    之前已经写过一篇关于vue权限路由实现方式总结的文章,经过一段时间的踩坑和总结,下面说说目前我认为比较"完美"的一种方案:菜单与路由完全由后端提供. 菜单与路由完全由后端返回 这种 ...

  9. JavaWeb项目WebContent下的资源文件无法引用

    JavaWeb项目引用资源的时候尽量使用绝对路径. 作者在帮助同学完善其JavaWeb项目端页面的时候,css样式文件怎么也引用不了. 第一个想到的是:是不是文件路径写错了? 于是,作者换了绝对路径, ...

  10. [PHP] 重回基础(Array相关函数)

    使用函数array_keys(),得到数组中所有的键,参数:数组 $arr=array(); $arr['one']="one"; $arr['two']="two&qu ...