IOS項目BO

#import "ViewController.h"#import "OneViewController.h"#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height@interface ViewController ()@property(nonatomic,strong)UIScrollView *scroll;

@end

@implementation ViewController

-(void)scrollTop{

? ? //創(chuàng)建滾動試圖

? ? _scroll = [[UIScrollView alloc] initWithFrame:self.view.frame];

? ? //設置代理

? ? _scroll.delegate = self;

? ? //設置滾動范圍

? ? _scroll.contentSize = CGSizeMake(SCREEN_WIDTH * 3, SCREEN_HEIGHT);

? ? //設置分頁滾動

? ? _scroll.pagingEnabled = YES;

? ? //添加到視圖上

? ? [self.view addSubview:_scroll];

? ? //利用循環(huán)創(chuàng)建imageview

? ? for (int i = 0; i< 3; i++) {

? ? ? ? UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];

? ? ? ? imageV.image = [UIImage imageNamed:@"4 2"];

? ? ? ? imageV.userInteractionEnabled = YES;

? ? ? ? //添加到滾動視圖上

? ? ? ? [_scroll addSubview:imageV];

? ? ? ? //判斷創(chuàng)建button

? ? ? ? if (i == 2) {

? ? ? ? ? ? UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

? ? ? ? ? ? btn.frame = CGRectMake((SCREEN_WIDTH - SCREEN_WIDTH / 6)/2, SCREEN_HEIGHT - 40*2, SCREEN_WIDTH / 6, 40);

? ? ? ? ? ? [btn setTitle:@"進入播放" forState:UIControlStateNormal];

? ? ? ? ? ? [btn addTarget:self action:@selector(btn1) forControlEvents:UIControlEventTouchUpInside];

? ? ? ? ? ? //將button添加到圖片上

? ? ? ? ? ? [imageV addSubview:btn];

? ? ? ? }

? ? }

}

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? //調(diào)用scrollview

? ? [self scrollTop];

}

//button點擊事件

-(void)btn1{

? ? NSLog(@"進入首頁");

? ? OneViewController *one = [[OneViewController alloc] init];

? ? [self presentViewController:one animated:YES completion:^{

? ? }];

}

@end

#import "OneViewController.h"#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height@interface OneViewController (){

? ? UIButton *_lastButton;

? ? UIView *view;

? ? UIImageView *imagea;

? ? UITableView *table;

? ? NSMutableArray *arrtab;

}

@property(nonatomic,strong)UIButton *butten,*buttenCenter,*button;

@property(nonatomic,strong)UIScrollView *scrollV,*scrollCenter,*scrool;;

@end

@implementation OneViewController

-(void)buttenTopA{

? ? NSArray *arr = @[@"我的",@"樂庫",@"唱歌"];

? ? for (int i = 0; i< 3; i++) {

? ? ? ? _butten = [UIButton buttonWithType:UIButtonTypeCustom];

? ? ? ? _butten.frame = CGRectMake(SCREEN_WIDTH / 4* i+SCREEN_WIDTH / 6, 20, SCREEN_WIDTH / 6, 40);

? ? ? ? [_butten setTitle:arr[i] forState:UIControlStateNormal];

? ? ? ? [_butten setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

? ? ? ? [_butten setTitleColor:[UIColor grayColor] forState:UIControlStateSelected];

? ? ? ? _butten.selected = YES;

? ? ? ? [_butten addTarget:self action:@selector(butten:) forControlEvents:UIControlEventTouchUpInside];

? ? ? ? _butten.tag = 1000+i;

? ? ? ? [self.view addSubview:_butten];

? ? }

? ? UIButton *buttem = [UIButton buttonWithType:UIButtonTypeRoundedRect];

? ? buttem.frame = CGRectMake(10, 20, 40, 40);

? ? [buttem setTitle:@"??" forState:UIControlStateNormal];

? ? [self.view addSubview:buttem];

}

-(void)scrollView{

? ? //創(chuàng)建滾動試圖

? ? _scrollV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT)];

? ? //設置代理

? ? _scrollV.delegate = self;

? ? //設置滾動范圍

? ? _scrollV.contentSize = CGSizeMake(SCREEN_WIDTH * 2, 0);

? ? //設置分頁滾動

? ? _scrollV.pagingEnabled = YES;

? ? //添加到視圖上

? ? [self.view addSubview:_scrollV];

? ? for (int i = 0; i< 3; i++) {

? ? ? ? UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];

? ? ? ? if (i == 0) {

? ? ? ? ? ? view1.backgroundColor = [UIColor greenColor];

? ? ? ? }else if (i == 1){

? ? ? ? ? ? view1.backgroundColor = [UIColor clearColor];

? ? ? ? }else{

? ? ? ? ? ? view1.backgroundColor = [UIColor cyanColor];

? ? ? ? }

? ? ? ? [_scrollV addSubview:view1];

? ? }

}

-(void)scrollCenterA{

? ? //創(chuàng)建滾動試圖

? ? _scrollCenter = [[UIScrollView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, 40)];

? ? //設置代理

? ? _scrollCenter.delegate = self;

? ? _scrollCenter.backgroundColor = [UIColor blueColor];

? ? //設置滾動范圍

? ? _scrollCenter.contentSize = CGSizeMake(SCREEN_WIDTH * 2, 0);

? ? //設置分頁滾動

? ? //_scrollCenter.pagingEnabled = YES;

? ? //添加到視圖上

? ? [_scrollV addSubview:_scrollCenter];

? ? NSArray *array = @[@"排行",@"歌手",@"電臺",@"人群",@"推薦",@"心情",@"主題",@"兒歌"];

? ? for (int i = 0; i< 8; i++) {

? ? ? ? _buttenCenter = [UIButton buttonWithType:UIButtonTypeCustom];

? ? ? ? _buttenCenter.frame = CGRectMake(SCREEN_WIDTH / 6* i, 0, SCREEN_WIDTH / 6, 40);

? ? ? ? [_buttenCenter setTitle:array[i] forState:UIControlStateNormal];

? ? ? ? [_buttenCenter setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

? ? ? ? [_buttenCenter setTitleColor:[UIColor grayColor] forState:UIControlStateSelected];

? ? ? ? _buttenCenter.selected = YES;

? ? ? ? [_buttenCenter addTarget:self action:@selector(clickButten:) forControlEvents:UIControlEventTouchUpInside];

? ? ? ? _buttenCenter.tag = 1000+i;

? ? ? ? [_scrollCenter addSubview:_buttenCenter];

? ? }

}

-(void)buttonLeft{

? ? NSArray *array1 = @[@"推薦",@"心情",@"主題",@"人群",@"場景",@"曲風",@"雨中",@"樂器",@"歌手"];

? ? for (int i = 0; i< 8; i++) {

? ? ? ? _button = [UIButton buttonWithType:UIButtonTypeCustom];

? ? ? ? _button.frame = CGRectMake(0, SCREEN_HEIGHT / 10*i, SCREEN_WIDTH / 6, 40);

? ? ? ? [_button setTitle:array1[i] forState:UIControlStateNormal];

? ? ? ? [_button setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];

? ? ? ? [_button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];

? ? ? ? _button.selected = YES;

? ? ? ? [_button addTarget:self action:@selector(btn1a:) forControlEvents:UIControlEventTouchUpInside];

? ? ? ? _button.tag = 1000+i;

? ? ? ? [imagea addSubview:_button];

? ? }

}

-(void)scroolView{

? ? //創(chuàng)建滾動試圖

? ? _scrool = [[UIScrollView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH, 40, SCREEN_WIDTH, SCREEN_HEIGHT)];

? ? //設置代理

? ? _scrool.delegate = self;

? ? //設置滾動范圍

? ? _scrool.contentSize = CGSizeMake(SCREEN_WIDTH * 8, 0);

? ? //設置分頁滾動

? ? _scrool.pagingEnabled = YES;

? ? //添加到視圖上

? ? [_scrollV addSubview:_scrool];

? ? for (int i = 0; i< 8; i++) {

? ? ? ? view = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];

? ? ? ? if (i == 0) {

? ? ? ? ? ? view.backgroundColor = [UIColor greenColor];

? ? ? ? }else if (i == 1){

? ? ? ? ? ? view.backgroundColor = [UIColor clearColor];

? ? ? ? }else if (i == 2){

? ? ? ? ? ? view.backgroundColor = [UIColor yellowColor];

? ? ? ? ? ? imagea = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 104 - 65)];

? ? ? ? ? ? imagea.image = [UIImage imageNamed:@"u=1155422752,2817714038&fm=27&gp=0"];

? ? ? ? ? ? imagea.userInteractionEnabled = YES;

? ? ? ? ? ? [view addSubview:imagea];

? ? ? ? ? ? UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 170, SCREEN_WIDTH, 65)];

? ? ? ? ? ? toolbar.barTintColor = [UIColor grayColor];

? ? ? ? ? ? [imagea addSubview:toolbar];

? ? ? ? ? ? UIImageView *imageaa = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 65)];

? ? ? ? ? ? imageaa.image = [UIImage imageNamed:@"4EA8715B392B9CFCF1B7000138338BC7"];

? ? ? ? ? ? [toolbar addSubview:imageaa];

? ? ? ? ? ? UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(70, 0, 100, 35)];

? ? ? ? ? ? label.text = @"白松";

? ? ? ? ? ? [toolbar addSubview:label];

? ? ? ? ? ? UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(70, 35, 100, 35)];

? ? ? ? ? ? label1.text = @"松";

? ? ? ? ? ? label1.font = [UIFont systemFontOfSize:14];

? ? ? ? ? ? [toolbar addSubview:label1];

? ? ? ? ? ? UIImageView *imagebb = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 200, 20, 40, 40)];

? ? ? ? ? ? imagebb.image = [UIImage imageNamed:@"u=2132620800,3533375095&fm=200&gp=0"];

? ? ? ? ? ? [toolbar addSubview:imagebb];

? ? ? ? ? ? UIImageView *imagebba = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 120, 20, 40, 40)];

? ? ? ? ? ? imagebba.image = [UIImage imageNamed:@"u=2132620800,3533375095&fm=200&gp=0"];

? ? ? ? ? ? [toolbar addSubview:imagebba];

? ? ? ? ? ? UIImageView *imagebbc = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 60, 20, 40, 40)];

? ? ? ? ? ? imagebbc.image = [UIImage imageNamed:@"u=2132620800,3533375095&fm=200&gp=0"];

? ? ? ? ? ? [toolbar addSubview:imagebbc];

? ? ? ? }else if (i == 3){

? ? ? ? ? ? view.backgroundColor = [UIColor clearColor];

? ? ? ? }else if (i == 4){

? ? ? ? ? ? view.backgroundColor = [UIColor orangeColor];

? ? ? ? }else if (i == 5){

? ? ? ? ? ? view.backgroundColor = [UIColor cyanColor];

? ? ? ? }else if (i == 6){

? ? ? ? ? ? view.backgroundColor = [UIColor greenColor];

? ? ? ? }else if (i == 7){

? ? ? ? ? ? view.backgroundColor = [UIColor grayColor];

? ? ? ? }else{

? ? ? ? ? ? view.backgroundColor = [UIColor redColor];

? ? ? ? }

? ? ? ? [_scrool addSubview:view];

? ? }

}

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? self.view.backgroundColor = [UIColor cyanColor];

? ? [self buttenTopA];

? ? [self scrollView];

? ? [self scrollCenterA];

? ? [self scroolView];

? ? [self buttonLeft];

}

-(void)butten:(UIButton *)sender{

? ? sender.selected = NO;

? ? _lastButton.selected = YES;

? ? _lastButton = sender;

? ? _scrollV.contentOffset = CGPointMake((sender.tag - 1000)*SCREEN_WIDTH, 0);

}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

? ? int offSet = _scrollV.contentOffset.x;

? ? int index = offSet / SCREEN_WIDTH;

? ? NSLog(@"%d",index);

? ? int btnTag = 1000+index;

? // UIButton *btn = [self.view viewWithTag:btnTag];

}

-(void)clickButten:(UIButton *)sendera{

? ? sendera.selected = NO;

? ? _lastButton.selected = YES;

? ? _lastButton = sendera;

? ? _scrool.contentOffset = CGPointMake((sendera.tag - 1000)*SCREEN_WIDTH, 0);

}

-(void)btn1a:(UIButton *)senderbtn{

? ? senderbtn.selected = NO;

? ? _lastButton.selected = YES;

? ? _lastButton = senderbtn;

? ? table = [[UITableView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 6, 0, SCREEN_WIDTH - SCREEN_WIDTH / 6, SCREEN_HEIGHT - 180)];

? ? table.delegate = self;

? ? table.dataSource = self;

? ? table.rowHeight = 80;

? ? table.backgroundColor = [UIColor clearColor];

? ? [imagea addSubview:table];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

? ? return 7;

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

? ? static NSString *str = @"cell";

? ? UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];

? ? if (!cell) {

? ? ? ? cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];

? ? }

? ? NSArray *arr = @[@"index",@"index",@"index",@"index",@"index",@"index",@"index"];

? ? NSArray *arr2 = @[@"一人一首成名曲",@"經(jīng)典懷舊",@"網(wǎng)絡熱歌",@"秋天",@"90后電臺",@"雨天",@"理發(fā)店"];

? ? NSArray *arr3 = @[@"3200.23萬人在聽",@"320.23萬人在聽",@"5173.23萬人在聽",@"886.01萬人在聽",@"37.9821萬人在聽",@"3721.00萬人在聽",@"5432.09萬人在聽"];

? ? cell.imageView.image = [UIImage imageNamed:arr[indexPath.row]];

? ? cell.textLabel.text = arr2[indexPath.row];

? ? cell.detailTextLabel.text = arr3[indexPath.row];

? ? cell.backgroundColor = [UIColor clearColor];

? ? return cell;

}

@end

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,578評論 6 544
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,701評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,691評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,974評論 1 318
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,694評論 6 413
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 56,026評論 1 329
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 44,015評論 3 450
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 43,193評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,719評論 1 336
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 41,442評論 3 360
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,668評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,151評論 5 365
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 44,846評論 3 351
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,255評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,592評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,394評論 3 400
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,635評論 2 380

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