ifish/Ifish/views/IfishPopView/LXPopView.m

110 lines
3.0 KiB
Objective-C

//
// LXPopView.m
// ifishPop
//
// Created by imac on 16/7/29.
// Copyright © 2016年 xiang. All rights reserved.
//
#import "LXPopView.h"
#import "PopCell.h"
@implementation LXPopView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.backgroundColor = [UIColor clearColor];
}
return self;
}
-(void)layoutSubviews{
[self initTabWithFrame];
}
-(void)initTabWithFrame{
UIImageView *bakc=[[UIImageView alloc] initWithFrame:CGRectMake(0, 10, self.frame.size.width, self.frame.size.height)];
bakc.image = self.backgroundImage;
//bakc.backgroundColor = [UIColor redColor];
[self addSubview:bakc];
self.tableView = [[UITableView alloc] init]
;
self.tableView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
//self.tableView.frame = CGRectMake(0,12.0, self.frame.size.width, self.frame.size.height);
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = NO;
self.tableView.backgroundColor = [UIColor colorWithRed:40.0/256.0 green:40.0/256.0 blue:40.0/256.0 alpha:1];
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
[self.tableView setSeparatorColor:[UIColor colorWithRed:30.0/256.0 green:30.0/256.0 blue:30.0/256.0 alpha:1]];
}
[self addSubview:self.tableView];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.titles count];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//带点九图
//return (self.frame.size.height - 12) /2;
return (self.frame.size.height - 12) /[self.titles count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PopCell *cell =[tableView dequeueReusableCellWithIdentifier:@"PopCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"PopCell" owner:self options:nil]lastObject];
}
cell.nametitle.text = self.titles[indexPath.row];
cell.backgroundColor = [UIColor colorWithRed:40.0/256.0 green:40.0/256.0 blue:40.0/256.0 alpha:1];
cell.nametitle.textColor = [UIColor whiteColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.popViewHeaderImg.image = [UIImage imageNamed:self.titleImgs[indexPath.row]];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.delegate disSelectedPopViewIndex:indexPath];
}
@end