栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 移动开发 > iOS

iOS实现渐变按钮Gradient Button的方法示例

iOS 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

iOS实现渐变按钮Gradient Button的方法示例

GradientCategory

使用category实现gradient

简介

本例主要采用了类别来实现了给按钮设置渐变色的功能

当然,里边也有一些别的对比实现方法.

各位看官如有发现什么bug,请批评指正!

效果图


来看.h文件

#import 

typedef NS_ENUM(NSInteger, GradientType) {
 GradientFromTopToBottom = 1,   //从上到下
 GradientFromLeftToRight,    //从做到右
 GradientFromLeftTopToRightBottom,  //从上到下
 GradientFromLeftBottomToRightTop  //从上到下
};

@interface UIImage (Gradient)


- (UIImage *)createImageWithSize:(CGSize)imageSize gradientColors:(NSArray *)colorArr percentage:(NSArray *)percents gradientType:(GradientType)gradientType;

@end


#import 

#import "UIImage+Gradient.h"

@interface UIButton (Gradient)


- (UIButton *)gradientButtonWithSize:(CGSize)btnSize colorArray:(NSArray *)clrs percentageArray:(NSArray *)percent gradientType:(GradientType)type;

@end

实现

请大家移步Github (本地下载)

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对考高分网的支持。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/166121.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号