ios CCUIHilightedLabel.m

//
//  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

 

//
//  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. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-23 06:06:03       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-23 06:06:03       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-23 06:06:03       45 阅读
  4. Python语言-面向对象

    2024-07-23 06:06:03       55 阅读

热门阅读

  1. 动态内存管理

    2024-07-23 06:06:03       12 阅读
  2. linux协议栈之FDB表

    2024-07-23 06:06:03       14 阅读
  3. 记录贴-VUE相关

    2024-07-23 06:06:03       17 阅读
  4. ios CCUIImage.m

    2024-07-23 06:06:03       16 阅读
  5. unity和安卓的so文件联合使用

    2024-07-23 06:06:03       16 阅读
  6. 智能马桶的工作原理

    2024-07-23 06:06:03       15 阅读
  7. gitlab查询分支API显示不全,只有20个问题

    2024-07-23 06:06:03       14 阅读
  8. Linux Vim教程(四):文本编辑与修改技巧

    2024-07-23 06:06:03       14 阅读
  9. Esxi 上的 CentOS 7.6 系统中搭建本地 Yum 源

    2024-07-23 06:06:03       17 阅读
  10. Android 多用户问题

    2024-07-23 06:06:03       18 阅读
  11. QT 4.8版本的Ubuntu2004编译错误的解决方案

    2024-07-23 06:06:03       15 阅读
  12. 算法1--双指针

    2024-07-23 06:06:03       14 阅读