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

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

相关推荐
梅孔立7 分钟前
【实用教程】python 批量解析 EML 邮件文件 存成txt ,可以利用 AI 辅助快速生成年终总结
开发语言·python
c#上位机18 分钟前
C#异步编程之async、await
开发语言·c#
郑州光合科技余经理31 分钟前
实战分享:如何构建东南亚高并发跑腿配送系统
java·开发语言·javascript·spring cloud·uni-app·c#·php
爱装代码的小瓶子32 分钟前
【c++进阶】C++11新特性:一切皆可{}初始化
开发语言·c++·visual studio
yaoxin52112335 分钟前
273. Java Stream API - Stream 中的中间操作:Mapping 操作详解
java·开发语言·python
技术小甜甜36 分钟前
[Python实战] 告别浏览器驱动烦恼:用 Playwright 优雅实现网页自动化
开发语言·python·自动化
vortex536 分钟前
Bash 替换机制(一):命令替换与进程替换
开发语言·chrome·bash
小徐Chao努力42 分钟前
【GO】Gin 框架从入门到精通完整教程
开发语言·golang·gin
她说..43 分钟前
手机验证码功能实现(附带源码)
java·开发语言·spring boot·spring·java-ee·springboot
柯南二号44 分钟前
【大前端】【iOS】iOS 真实项目可落地目录结构方案
前端·ios