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