ios CCUIHilightedLabel.m

objectivec 复制代码
//
//  CCUIHilightedLabel.h
//  CCFC
//
//


#import <UIKit/UIKit.h>


@class CCUIHilightedLabel;


@protocol UIHilightedLabelDelegate


- (void)onHilightedLabelTouchedBegan:(CCUIHilightedLabel *)hilightedLabel;


@end




// a kind of UILabel that can be touched to hilighted
@interface CCUIHilightedLabel : UILabel 
{
        id              _delegate;
        BOOL            _isHilighted;
        BOOL            _disableHilight;
    UIColor         *_hilightedColor;
}


@property(nonatomic, assign)    id              delegate;
@property(nonatomic, assign)    BOOL    isHilighted;
@property(nonatomic, assign)    BOOL    disableHilight;
@property(nonatomic, retain)    UIColor *hilightedColor;


- (id)initWithFrame:(CGRect)frame;
- (void)setIsHilighted:(BOOL)isHighlighted;


@end
objectivec 复制代码
//
//  CCUIHilightedLabel.m
//  CCFC
//
//


#import "CCUIHilightedLabel.h"




@implementation CCUIHilightedLabel


@synthesize isHilighted     = _isHilighted;
@synthesize disableHilight  = _disableHilight;
@synthesize delegate        = _delegate;
@synthesize hilightedColor  = _hilightedColor;


- (id)initWithFrame:(CGRect)frame 
{
    
    self = [super initWithFrame:frame];
    if (self)
    {
        
    }
    return self;
}


- (void)dealloc 
{
    [super dealloc];
}




- (void)setIsHilighted:(BOOL)isHighlighted
{
        if(isHighlighted)
        {
                _isHilighted = TRUE;
                super.textColor = _hilightedColor;
        }
        else
        {
                _isHilighted = FALSE;
                super.textColor = [UIColor blackColor];
        }
}




- (void)drawRect:(CGRect)rect 
{
        [super drawRect:rect];
}




- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
        if(!_disableHilight)
        {
                _isHilighted = TRUE;
                super.textColor = _hilightedColor;
                [_delegate onHilightedLabelTouchedBegan:self];
        }
}


@end

微风不燥,阳光正好,你就像风一样经过这里,愿你停留的片刻温暖舒心。

我是程序员小迷(致力于C、C++、Java、Kotlin、Android、iOS、Shell、JavaScript、TypeScript、Python等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。

欢迎关注。助您在编程路上越走越好!

相关推荐
xingpanvip8 分钟前
星盘接口开发文档:组合三限盘接口指南
android·开发语言·前端·python·php·lua
无忧.芙桃22 分钟前
现代C++讲解之变量模板,泛型lambda,函数返回类型推导的使用
开发语言·c++·visualstudio
格林威44 分钟前
工业视觉检测:两大主流异常检测开源框架深度对比(PatchCore vs SPADE)
开发语言·人工智能·深度学习·数码相机·计算机视觉·视觉检测·工业相机
2zcode1 小时前
基于Matlab元胞自动机模拟(CA)静态再结晶过程
开发语言·matlab·静态再结晶
研究点啥好呢1 小时前
滴滴Go后端开发工程师面试题精选:10道高频考题+答案解析
java·开发语言·golang
Levin__NLP_CV_AIGC1 小时前
py文件中文件复制方法
开发语言·python
yong99901 小时前
EKF-SLAM在MATLAB上的仿真实现
开发语言·matlab
广州山泉婚姻1 小时前
C语言三种基本程序结构详解
c语言·开发语言
上弦月-编程1 小时前
【C语言】函数栈帧的创建与销毁(底层原理)
c语言·开发语言
eqwaak01 小时前
PyTorch张量操作全攻略:从入门到精通
开发语言·人工智能·pytorch·python