美文网首页
iOS 渐变背景label

iOS 渐变背景label

作者: NicoalsNC | 来源:发表于2019-10-18 12:54 被阅读0次
demo效果图.png

NCGradientLabel

使用集成:

导入头文件

#import "NCGradientLabel.h"

创建NCGradientLabel对象

NCGradientLabel *actionLabel = [NCGradientLabel createLabelWithFrame:CGRectMake(100, 100,100, 52)
                        withTextAlignment:NSTextAlignmentCenter
                            withFont:[UIFont boldSystemFontOfSize:18.0]
                        withBackColor:[UIColor clearColor]
                        withTextColor:[UIColor whiteColor]
                            withTag:1000];

设置颜色渐变方向

actionLabel.gradientColors = @[[UIColor getColorWithHexString:@"#FF9900"],[UIColor getColorWithHexString:@"#FFd122"]];
actionLabel.directionType = type;

方向枚举值

enum GradientDirectionType{
    eGradientDirectionType_topToBottom = 0,////从上到下
    eGradientDirectionType_leftToRight = 1,//从左到右
    eGradientDirectionType_leftBottomToRightTop = 2,////从左下到右上
    eGradientDirectionType_leftTopToRightBootom = 3,//从左上到右下
};

文章若有不对地方,欢迎批评指正
NCGradientLabel如果喜欢或者有用请给star,谢谢

相关文章

网友评论

      本文标题:iOS 渐变背景label

      本文链接:https://www.haomeiwen.com/subject/fjeimctx.html