AYVibrantButton

简介:

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.

 

目录
相关文章
|
11月前
|
存储 NoSQL 容灾
轻松掌握组件启动之MongoDB(上):高可用复制集架构环境搭建
本文介绍了MongoDB复制集的架构和特点,强调了使用复制集提供数据的高可用性和冗余性的重要性。复制集由Primary节点和Secondary节点组成,确保数据一致性。复制集还具有数据分发、读写分离和异地容灾等附加功能。使用MongoDB复制集可以提供稳定可靠的数据存储和高可用性。
131 1
轻松掌握组件启动之MongoDB(上):高可用复制集架构环境搭建
|
3月前
|
弹性计算 人工智能 运维
OS Copilot实例评测说明
**OS Copilot 概览与体验反馈** OS Copilot是阿里云针对Alibaba Cloud Linux的智能助手,提供自然语言交互、命令辅助及运维优化。在使用中遇到问题,包括ECS跳转报错、不显示查询结果、生成的监控代码需优化、命令行交互有待改进。产品对新人上手有一定难度,指引文档不够清晰。用户作为技术经理,认为其在命令查找和脚本编写上有帮助,评分7/10,愿意推荐并参与开发。
|
OceanBase 关系型数据库 Oracle
十年磨一剑:从2009启动“去IOE”工程到2019年OceanBase拿下TPC-C世界第一
从2009年启动“去IOE”到2019年OceanBase拿下TPC-C世界第一,这十年漫长的时光,有无数次可能让OceanBase夭折,坚持到今天真是一个特别了不起的奇迹。
754 0
十年磨一剑:从2009启动“去IOE”工程到2019年OceanBase拿下TPC-C世界第一
|
Java
关于软件工程的几点思考
来阿里已经很长一段时间了,从刚开始来我就想写点关于软件工程,服务化和开发效率的个人理解,却一直没有想好怎么写,一直在心里筹划思考该如何准确地表达我所想的内容,也能够给别人带来一些有价值的信息,但是拖了很久了,想想还是写出来罢,没有必要追求那么完美,欢迎拍砖。(顺便说下,有观点认为拖延症患者都有或多或少的完美主义倾向,处女座的同学验证下哈。) ## 1 什么是软件工程? 服务化其实是一个软
2377 0
|
存储 Kubernetes Docker
Kubernetes节点资源耗尽状态的处理
今天上午一到工位,就收到来自同事的“投诉”:私有云上的Kubernetes cluster中的一个node似乎不工作了,因为专门部署于那个节点上的应用挂掉了,并且长时间没有恢复。这个公司私有云上Kubernetes集群是v1.7.5版本,部署于双节假期之前。
4562 0
|
SEO 搜索推荐 数据可视化
如何仅使用内部链接策略来提高搜索排名
如何仅使用内部链接策略来提高搜索排名 网站架构修改的三个例子,在数字营销中提供了大量的SEO收益。 链接,即使在网站内,也显示内容之间的关系。它们在页面之间传递价值和重要性。更重要的是,内部链接定义了您网站的结构。
1820 0