滾動視圖 自封裝

#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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末笙蒙,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子庆锦,更是在濱河造成了極大的恐慌捅位,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,496評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異艇搀,居然都是意外死亡尿扯,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評論 3 392
  • 文/潘曉璐 我一進店門焰雕,熙熙樓的掌柜王于貴愁眉苦臉地迎上來衷笋,“玉大人,你說我怎么就攤上這事淀散∮依常” “怎么了?”我有些...
    開封第一講書人閱讀 162,632評論 0 353
  • 文/不壞的土叔 我叫張陵档插,是天一觀的道長慢蜓。 經(jīng)常有香客問我,道長郭膛,這世上最難降的妖魔是什么晨抡? 我笑而不...
    開封第一講書人閱讀 58,180評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮则剃,結(jié)果婚禮上耘柱,老公的妹妹穿的比我還像新娘。我一直安慰自己棍现,他們只是感情好调煎,可當我...
    茶點故事閱讀 67,198評論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著己肮,像睡著了一般士袄。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上谎僻,一...
    開封第一講書人閱讀 51,165評論 1 299
  • 那天娄柳,我揣著相機與錄音,去河邊找鬼艘绍。 笑死赤拒,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的诱鞠。 我是一名探鬼主播挎挖,決...
    沈念sama閱讀 40,052評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼般甲!你這毒婦竟也來了肋乍?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,910評論 0 274
  • 序言:老撾萬榮一對情侶失蹤敷存,失蹤者是張志新(化名)和其女友劉穎墓造,沒想到半個月后堪伍,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,324評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡觅闽,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,542評論 2 332
  • 正文 我和宋清朗相戀三年帝雇,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片蛉拙。...
    茶點故事閱讀 39,711評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡尸闸,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出孕锄,到底是詐尸還是另有隱情吮廉,我是刑警寧澤,帶...
    沈念sama閱讀 35,424評論 5 343
  • 正文 年R本政府宣布畸肆,位于F島的核電站宦芦,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏轴脐。R本人自食惡果不足惜调卑,卻給世界環(huán)境...
    茶點故事閱讀 41,017評論 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望大咱。 院中可真熱鬧恬涧,春花似錦、人聲如沸碴巾。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,668評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽厦瓢。三九已至现使,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間旷痕,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,823評論 1 269
  • 我被黑心中介騙來泰國打工顽冶, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留欺抗,地道東北人。 一個月前我還...
    沈念sama閱讀 47,722評論 2 368
  • 正文 我出身青樓强重,卻偏偏與公主長得像绞呈,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子间景,可洞房花燭夜當晚...
    茶點故事閱讀 44,611評論 2 353

推薦閱讀更多精彩內(nèi)容