#import "ViewController.h"
#import "ImageScrollView.h"
#import "AppDelegate.h"
#import "RootViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? NSArray *imgNameArr = @[@"guidePage1",@"guidePage2",@"guidePage3"];
? ? CGRect confirmBtnFrame = CGRectMake(self.view.frame.size.width - 200, 80, 150, 40);
? ? ImageScrollView *guide = [[ImageScrollView alloc]initWithFrame:self.view.frame style:ImageScrollType_Guide images:imgNameArr confirmBtnTitle:@"立即體驗" confirmBtnTitleColor:[UIColor blueColor] confirmBtnFrame:confirmBtnFrame autoScrollTimeInterval:0 delegate:self];
? ? //添加滾動式圖
? ? [self.view addSubview:guide];
? ? //添加分頁控件
? ? [guide addPageControlToSuperView:self.view];
}
-(void)experienceDidHandle{
? ? RootViewController *rootVC = [[RootViewController alloc] init];
? ? AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
? ? app.window.rootViewController = rootVC;
}
- (void)didReceiveMemoryWarning {
? ? [super didReceiveMemoryWarning];
? ? // Dispose of any resources that can be recreated.
}
@end
無線輪播
#import "RootViewController.h"
#import "ImageScrollView.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? NSArray *arr = @[@"man1.jpg",@"man2.jpg",@"man3.jpg",@"man4.jpg"];
? ? ImageScrollView *banner = [[ImageScrollView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 350) style:ImageScrollType_Banner images:arr confirmBtnTitle:nil confirmBtnTitleColor:nil confirmBtnFrame:CGRectZero autoScrollTimeInterval:3 delegate:self];
? ? [self.view addSubview:banner];
}
-(void)bannerImageDidHandleWithIndex:(NSInteger)index{
? ? NSLog(@"點擊了第%ld張圖",index+1);
}
#import "ViewController.h"
#import "AppDelegate.h"
#import "ImageScrollView.h"
#import "TabBarViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? NSArray *imgNameArr = @[@"guidePage1",@"guidePage2",@"guidePage3"];
? ? CGRectconfirmBtnFrame =CGRectMake(self.view.frame.size.width-200,80,150,40);
? ? ImageScrollView *guide = [[ImageScrollView alloc]initWithFrame:self.view.frame style:ImageScrollType_Guide images:imgNameArr confirmBtnTitle:@"立即體驗" confirmBtnTitleColor:[UIColor redColor] confirmBtnFrame:confirmBtnFrame autoScrollTimeInterval:3 delegate:self];
? ? //添加滾動式圖
? ? [self.viewaddSubview:guide];
? ? //添加分頁控件
? ? [guideaddPageControlToSuperView:self.view];
}
-(void)experienceDidHandle{
? ? TabBarViewController *tabVC = [[TabBarViewController alloc] init];
? ? AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
? ? app.window.rootViewController = tabVC;
}
@end
//控制器初始化
? ? FirstViewController *firstVC = [[FirstViewController alloc] init];
? ? SecondViewController *secondVC = [[SecondViewController alloc] init];
? ? ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
? ? FouthViewController *fouthVC = [[FouthViewController alloc] init];
? ? FiveViewController *fiveVC = [[FiveViewController alloc] init];
? ? //創(chuàng)建導航控制器
? ? UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:firstVC];
? ? UINavigationController *secondNav = [[UINavigationController alloc] initWithRootViewController:secondVC];
? ? UINavigationController *thirdNav = [[UINavigationController alloc] initWithRootViewController:thirdVC];
? ? UINavigationController *fouthNav = [[UINavigationController alloc] initWithRootViewController:fouthVC];
? ? UINavigationController *fiveNav = [[UINavigationController alloc] initWithRootViewController:fiveVC];
? ? //添加標簽
? ? firstNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"推薦" image:[UIImage imageNamed:@"1"] selectedImage:[UIImage imageNamed:@"1"]];
? ? secondNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"榜單" image:[UIImage imageNamed:@"2"] selectedImage:[UIImage imageNamed:@"2"]];
? ? thirdNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"分類" image:[UIImage imageNamed:@"3"] selectedImage:[UIImage imageNamed:@"3"]];
? ? fouthNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"搜索" image:[UIImage imageNamed:@"4"] selectedImage:[UIImage imageNamed:@"4"]];
? ? fiveNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"應(yīng)用管理" image:[UIImage imageNamed:@"5"] selectedImage:[UIImage imageNamed:@"5"]];
? ? //添加到視圖控制器上
? ? self.viewControllers=@[firstNav,secondNav,thirdNav,fouthNav,fiveNav];
? ? self.selectedViewController = thirdNav;
? ? self.tabBar.selectedImageTintColor = [UIColor redColor];
? ? self.tabBar.backgroundColor = [UIColor clearColor];
#import "ThirdViewController.h"
#import "ImageScrollView.h"
@interface ThirdViewController ()
{
? ? UITableView*table;
? ? ImageScrollView *banner;
? ? UIButton*Btn;
}
@end
@implementationThirdViewController
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? self.navigationItem.title = @"分類";
? ? self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
? ? table=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
? ? table.showsVerticalScrollIndicator = NO;
? ? table.rowHeight=80;
? ? table.delegate=self;
? ? table.dataSource=self;
? ? [self.view addSubview:table];
? ? NSArray *arr = @[@"man1.jpg",@"man2.jpg",@"man3.jpg",@"man4.jpg"];
? ? banner = [[ImageScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 180) style:ImageScrollType_Banner images:arr confirmBtnTitle:nil confirmBtnTitleColor:nil confirmBtnFrame:CGRectZero autoScrollTimeInterval:3 delegate:self];
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{
? ? return 5;
}
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
? ? staticNSString*ID =@"cell";
? ? UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
? ? if(!cell) {
? ? ? ? cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
? ? }
? ? if(indexPath.row==0) {
? ? ? ? [celladdSubview:banner];
? ? ? ? //添加分頁控件
? ? ? ? [banner addPageControlToSuperView:cell];
? ? }
? ? else{
? ? //添加按鈕
? ? ? ? Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
? ? ? ? Btn.frame=CGRectMake(self.view.frame.size.width-80,25,60,30);
? ? ? ? [Btn setTitle:@"安裝" forState:UIControlStateNormal];
? ? ? ? [Btn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
? ? ? ? Btn.backgroundColor = [UIColor groupTableViewBackgroundColor];
? ? ? ? Btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
? ? ? ? Btn.layer.borderWidth = 1.2;
? ? ? ? [celladdSubview:Btn];
? ? ? ? [Btn addTarget:self action:@selector(bian:) forControlEvents:UIControlEventTouchUpInside];
? ? ? ? cell.textLabel.text=@"青芒閱讀";
? ? ? ? cell.detailTextLabel.text = @"學習教育";
? ? }
? ? returncell;
}
-(void)bannerImageDidHandleWithIndex:(NSInteger)index{
? ? NSLog(@"點擊了第%ld張圖",index+1);
}
-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{
? ? if(indexPath.row==0) {
? ? ? ? return200.0;
? ? }else
? ? {
? ? ? ? return80;
? ? }
}
-(void)bian:(UIButton*)sender{
? ? [sendersetTitle:@" √ 打開" forState:UIControlStateNormal];
? ? [sendersetTitleColor:[UIColor redColor] forState:UIControlStateNormal];
}
@end