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等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。

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

相关推荐
郝学胜-神的一滴1 分钟前
Qt 高级开发 022:栅格布局深度实战
开发语言·c++·qt·软件构建·用户界面
codeejun7 分钟前
每日一 Go-72、分布式事务 & 一致性:本地消息表、事务消息、SAGA、TCC怎么选?
开发语言·分布式·golang
Digitally7 分钟前
适用于安卓、iOS 和电脑的最新文件共享应用评测指南
android·ios·电脑
sycmancia9 分钟前
Qt——程序中的配置文件
开发语言·qt
赶在日落之前12 分钟前
使用conda-pack打包完整 Python 环境 + 依赖包,传到无网机器解压即用
开发语言·人工智能·python
雨落在了我的手上14 分钟前
Java数据结构(一):初识集合框架
java·开发语言
程序大视界14 分钟前
【C++ 从基础到项目实战】C++(三):函数进阶——重载、回调、递归与默认参数
开发语言·c++·cpp
爱喝水的鱼丶17 分钟前
SAP-ABAP:SAP 简单报表输出开发系列(共6篇)第二篇:SAP 报表数据筛选优化:选择屏幕自定义与查询效率提升
开发语言·数据库·学习·性能优化·sap·abap
HappyAcmen18 分钟前
8.角色 Prompt 模板
开发语言·python·prompt
oort12324 分钟前
VLStream 全开源决策式 AI 视频平台 技术视角完整说明
大数据·开发语言·人工智能·经验分享·python·开源·音视频