基本信息
源码名称:TQQTableView 实现qq效果
源码大小:0.03M
文件格式:.zip
开发语言:C/C++
更新时间:2015-11-16
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
//
// QQSectionHeaderView.m
// TQQTableView
//
// Created by Futao on 11-6-22.
// Copyright 2011 ftkey.com. All rights reserved.
//
#import "QQSectionHeaderView.h"
@implementation QQSectionHeaderView
@synthesize titleLabel, disclosureButton, delegate, section , opened;
-(id)initWithFrame:(CGRect)frame title:(NSString*)title section:(NSInteger)sectionNumber opened:(BOOL)isOpened delegate:(id)aDelegate{
if (self = [super initWithFrame:frame]) {
UITapGestureRecognizer *tapGesture = [[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(toggleAction:)] autorelease];
[self addGestureRecognizer:tapGesture];
self.userInteractionEnabled = YES;
section = sectionNumber;
delegate = aDelegate;
opened = isOpened;
CGRect titleLabelFrame = self.bounds;
titleLabelFrame.origin.x = 35.0;
titleLabelFrame.size.width -= 35.0;
CGRectInset(titleLabelFrame, 0.0, 5.0);
titleLabel = [[UILabel alloc] initWithFrame:titleLabelFrame];
titleLabel.text = title;
titleLabel.font = [UIFont boldSystemFontOfSize:17.0];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.backgroundColor = [UIColor clearColor];
[self addSubview:titleLabel];
disclosureButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
disclosureButton.frame = CGRectMake(0.0, 0.0, 35.0, 35.0);
[disclosureButton setImage:[UIImage imageNamed:@"carat.png"] forState:UIControlStateNormal];
[disclosureButton setImage:[UIImage imageNamed:@"carat-open.png"] forState:UIControlStateSelected];
disclosureButton.userInteractionEnabled = NO;
disclosureButton.selected = isOpened;
[self addSubview:disclosureButton];
self.backgroundColor = [UIColor brownColor];
}
return self;
}
-(IBAction)toggleAction:(id)sender {
disclosureButton.selected = !disclosureButton.selected;
if (disclosureButton.selected) {
if ([delegate respondsToSelector:@selector(sectionHeaderView:sectionOpened:)]) {
[delegate sectionHeaderView:self sectionOpened:section];
}
}
else {
if ([delegate respondsToSelector:@selector(sectionHeaderView:sectionClosed:)]) {
[delegate sectionHeaderView:self sectionClosed:section];
}
}
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code.
}
*/
- (void)dealloc {
[titleLabel release];
[disclosureButton release];
[super dealloc];
}
@end