导入文件HWPopTool.h弹窗视图
self.selectedIndex = 1; -------进入界面默认tabbar
#import "FuWuViewController.h"
#import "HWPopTool.h"
#import "CellTableViewCell.h"
@interface FuWuViewController ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource>
{
int k;
NSArray *arrimG;
}
@property (strong, nonatomic) UIView *contentView;
@property (strong, nonatomic) UIButton *popBtn;
@property (strong, nonatomic) UITableView *tbv;
@property (strong, nonatomic) NSArray *imgArr;
@property(strong , nonatomic) UIScrollView *scrollV;
@property(strong , nonatomic) NSTimer *timer;
@property (nonatomic , strong) UICollectionView *collV;
@end
@implementation FuWuViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"服务";
self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"email"] style:UIBarButtonItemStyleDone target:self action:nil];
[self.view addSubview:self.tbv];
[self.view addSubview:_scrollV];
[self setn];
_timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(change) userInfo:nil repeats:YES];
[self.view addSubview:self.collV];
}
-(void)setn{
self.view.backgroundColor = [UIColor whiteColor];
_contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, 200, 300)];
_contentView.backgroundColor = [UIColor clearColor];
_popBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_popBtn.frame = CGRectMake(0, 270, 200, 50);
[_popBtn setTitle:@"❎" forState:UIControlStateNormal];
[_popBtn addTarget:self action:@selector(closeAndBack) forControlEvents:UIControlEventTouchUpInside];
UIImageView *imageV = [[UIImageView alloc]initWithFrame:_contentView.bounds];
imageV.image = [UIImage imageNamed:@"jei"];
[_contentView addSubview:imageV];
// 看看pop效果把下面这一句加上
[_contentView addSubview:_popBtn];
[HWPopTool sharedInstance].shadeBackgroundType = ShadeBackgroundTypeSolid;
[HWPopTool sharedInstance].closeButtonType = ButtonPositionTypeRight;
[[HWPopTool sharedInstance] showWithPresentView:_contentView animated:YES];
}
- (void)closeAndBack {
[[HWPopTool sharedInstance] closeWithBlcok:^{
[self.navigationController popViewControllerAnimated:YES];
}];
}
-(UITableView *)tbv{
if (_tbv == nil) {
_tbv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
_tbv.delegate = self;
_tbv.dataSource = self;
[_tbv registerNib:[UINib nibWithNibName:@"CellTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
}
return _tbv;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 4;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0) {
return 1;
}
else if (section == 1){
return 1;
}
else if (section == 2){
return 1;
}
else{
return 4;
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (indexPath.section == 0) {
self.tbv.rowHeight = 135;
_imgArr = @[@"1",@"2",@"3",@"4"];
// 新特性界面.
// 滚动视图
_scrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 135)];
// 设置滚动的范围
_scrollV.contentSize = CGSizeMake(self.view.frame.size.width * 4 , 135);
// 设置分页
_scrollV.pagingEnabled = YES;
// 隐藏水平滚动条
_scrollV.showsHorizontalScrollIndicator = NO;
// 取消弹簧效果
_scrollV.bounces = NO;
// 初始化图片框
for (int i = 0 ; i < 4 ; i++){
// 创建了四个图片框
UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(i * self.view.frame.size.width, 0, self.view.frame.size.width, 135)];
// 设置图片
imgV.image = [UIImage imageNamed:_imgArr[i]];
// 设置图片与用户交互
imgV.userInteractionEnabled = YES;
[_scrollV addSubview:imgV];
[cell addSubview:_scrollV];
}
}
else if (indexPath.section == 1){
self.tbv.rowHeight = 160;
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(100,80);
layout.minimumLineSpacing = 0;
layout.minimumInteritemSpacing = 0;
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
_collV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width,160) collectionViewLayout:layout];
_collV.delegate = self;
_collV.dataSource = self;
_collV.backgroundColor = [UIColor lightGrayColor];
[_collV registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"coll"];
[cell addSubview:_collV];
}
else if (indexPath.section == 2){
self.tbv.rowHeight = 220;
UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 130, 220)];
UIImageView *img1 = [[UIImageView alloc]initWithFrame:CGRectMake(130, 0, 240, 110)];
UIImageView *img2 = [[UIImageView alloc]initWithFrame:CGRectMake(140,110,120,110)];
UIImageView *img3 = [[UIImageView alloc]initWithFrame:CGRectMake(260, 110, 120, 110)];
img.image = [UIImage imageNamed:@"11"];
img1.image = [UIImage imageNamed:@"22"];
img2.image = [UIImage imageNamed:@"33"];
img3.image = [UIImage imageNamed:@"44"];
[cell addSubview:img];
[cell addSubview:img1];
[cell addSubview:img2];
[cell addSubview:img3];
}else if (indexPath.section == 3){
self.tbv.rowHeight = 100;
NSArray *arr = @[@"1",@"2",@"3",@"4"];
cell.labelone.text = @"鸟巢";
cell.labeltwo.text = @"?106";
cell.labelthree.text = @"108万";
cell.imgname.image = [UIImage imageNamed:arr[indexPath.row]];
}
return cell;
}
-(void)change{
k++;
_scrollV.contentOffset = CGPointMake(k *self.view.frame.size.width, 0);
if (k > 3 ){
k = 0;
}
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 8;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"coll" forIndexPath:indexPath];
UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 80)];
//添加图片
imgV.image = [UIImage imageNamed:@"5"];
//添加到网格里面
[cell addSubview:imgV];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
return nil;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return nil;
}
@end
中间需要使用自定义cell xib 拖拽方式
CellTableViewCell.h
- (void)viewDidLoad {
[super viewDidLoad];
UILabel * textView = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 30)];
textView.text = @"八十多分卡是经典款拉屎的法师打发";
[self.view addSubview:textView];
[UIView animateWithDuration:3 delay:2 options:UIViewAnimationOptionRepeat animations:^{
//怎样的动画
textView.frame = CGRectMake(-self.view.frame.size.width, 100,self.view.frame.size.width , 30);
} completion:^(BOOL finished) {
NSLog(@"动画结束");
}];
}