123HHD

NSArray *lableArr = @[@"漢堡薯?xiàng)l",@"包子粥店",@"鮮花蛋糕",@"麻辣燙",@"地方菜",@"披薩意面",@"異國料理"];
NSArray *imgArr = @[@"1.png",@"2.png",@"3.png",@"4.png",@"5.png",@"6.png",@"7.png"];
for (int i = 0; i<lableArr.count; i++) {

                NSInteger index = i % 4;
                NSInteger page = i / 4;
                
                UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                btn.frame = CGRectMake(index * (Button_Width + Width_Space) + Start_X, page  * (Button_Height + Height_Space)+Start_Y, Button_Width, Button_Height);
                [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                btn.titleLabel.font = [UIFont systemFontOfSize:14];
                [btn setTitle:lableArr[i] forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:imgArr[i]] forState:UIControlStateNormal];
                [btn addTarget:self action:@selector(btn_click:) forControlEvents:UIControlEventTouchUpInside];
                [self initButton:btn];
                
                [cell addSubview:btn];
            }

            [myScrollView addSubview:view];
        }
        
        myScrollView.bounces = NO;
        
        myScrollView.pagingEnabled = YES;
        
        myScrollView.showsHorizontalScrollIndicator = NO;
        
        myScrollView.contentSize = CGSizeMake(WIDTH * 2, HEIGHT);
        
        myScrollView.delegate = self;
        
        [cell addSubview:myScrollView];
        pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(WIDTH /3, 170, WIDTH / 3, 40)];
        
        // 設(shè)置頁數(shù)
        pageControl.numberOfPages = 2;
        // 設(shè)置頁碼的點(diǎn)的顏色
        pageControl.pageIndicatorTintColor = [UIColor yellowColor];
        // 設(shè)置當(dāng)前頁碼的點(diǎn)顏色
        pageControl.currentPageIndicatorTintColor = [UIColor redColor];
        [cell addSubview:pageControl];
        
    }else if (indexPath.row == 1){
        UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100)];
        img.image = [UIImage imageNamed:@"grass.png"];
        [cell addSubview:img];
    }
    
}else if (indexPath.section == 1){
    
    // 標(biāo)題
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 50)];
    label.text = @"四星快餐";
    label.font = [UIFont systemFontOfSize:20 weight:1];
    [cell addSubview:label];
   
    // 圖片
    UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width / 4 + 20, 10, 50, 50)];
    img.image = [UIImage imageNamed:@"5.png"];
    
    [cell addSubview:img];
    
    // 標(biāo)題
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width / 2 + 10, 10, 100, 50)];
    label1.text = @"霸王餐";
    label1.font = [UIFont systemFontOfSize:20 weight:1];
    [cell addSubview:label1];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width / 2, 0, 2, 80)];
    line.backgroundColor = [UIColor colorWithRed:(237 / 255.0) green:(237 / 255.0) blue:(237 / 255.0) alpha:1.0];
    [cell addSubview:line];
    
    // 圖片
    UIImageView *img1 = [[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width / 4 * 3 + 20, 10, 50, 50)];
    img1.image = [UIImage imageNamed:@"2.png"];
    
    [cell addSubview:img1];
    
}else if (indexPath.section == 2){
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, 400, 30)];
    label.text = @"限時(shí)搶購   距離結(jié)束 00:31:00";
    label.font = [UIFont systemFontOfSize:18 weight:1];
    [cell addSubview:label];
    
    float x = 10;
    float y = 40;
    float w = 100;
    float h = 115;
    
    for (int i = 0; i<4; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setFrame:CGRectMake(w*i+x, y, w, h)];
        NSArray *lablelArr = @[@"扁豆?fàn)F面",@"驢肉火燒",@"黃燜雞米飯",@"莫利燉魚"];
        [btn setTitle:lablelArr[i] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"5"] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:14];
        [btn addTarget:self action:@selector(btn_click:) forControlEvents:UIControlEventTouchUpInside];
        [self initButton:btn];
        [cell addSubview:btn];
    }
}
return cell;

}
-(void)btn_click:(UIButton *)btn{
NSLog(@"點(diǎn)擊按鈕");
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

//求余
NSInteger index = scrollView.contentOffset.x / scrollView.frame.size.width;

pageControl.currentPage = index;

}

  • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

CGFloat cellHight = 0.0;

NSInteger sect = indexPath.section;

NSInteger row = indexPath.row;

switch (sect) {
        
    case 0:
        
        switch (row) {
                
            case 0:
                
                cellHight = 200;
                
                break;
                
            case 1:
                
                cellHight = 100;
                
                break;
                
            default:
                
                break;
                
        }
        
        break;
        
    case 1:
        
        switch (row) {
                
            case 0:
                
                cellHight = 80;
                
                break;
                
            case 1:
                
                cellHight = 80;
                
                break;
                
            default:
                break;
                
        }
        break;
        
    case 2:
        
        cellHight = 180;
        
        break;
        
    default:
        
        break;
        
}

return cellHight;

}

  • (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{
return 0.1;

}

  • (void)viewWillAppear:(BOOL)animated

{

self.navigationController.navigationBarHidden = YES;

}

  • (void)dragMoving:(UIControl *)c withEvent:ev

{
c.center = [[[ev allTouches] anyObject] locationInView:self.view];
}

  • (void)dragEnded:(UIControl *)c withEvent:ev
    {
    c.center = [[[ev allTouches] anyObject] locationInView:self.view];
    }
    -(void)buttonAction:(UIButton *)sender
    {
    NSLog(@"點(diǎn)擊購物車!");
    }

  • (UIStatusBarStyle)preferredStatusBarStyle{

    return UIStatusBarStyleLightContent;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末档叔,一起剝皮案震驚了整個(gè)濱河市荸实,隨后出現(xiàn)的幾起案子星瘾,更是在濱河造成了極大的恐慌谱姓,老刑警劉巖陵吸,帶你破解...
    沈念sama閱讀 222,252評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件脆烟,死亡現(xiàn)場離奇詭異绍妨,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)漠魏,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評論 3 399
  • 文/潘曉璐 我一進(jìn)店門倔矾,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人柱锹,你說我怎么就攤上這事哪自。” “怎么了奕纫?”我有些...
    開封第一講書人閱讀 168,814評論 0 361
  • 文/不壞的土叔 我叫張陵提陶,是天一觀的道長。 經(jīng)常有香客問我匹层,道長隙笆,這世上最難降的妖魔是什么锌蓄? 我笑而不...
    開封第一講書人閱讀 59,869評論 1 299
  • 正文 為了忘掉前任,我火速辦了婚禮撑柔,結(jié)果婚禮上瘸爽,老公的妹妹穿的比我還像新娘。我一直安慰自己铅忿,他們只是感情好剪决,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,888評論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著檀训,像睡著了一般柑潦。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上峻凫,一...
    開封第一講書人閱讀 52,475評論 1 312
  • 那天渗鬼,我揣著相機(jī)與錄音,去河邊找鬼荧琼。 笑死譬胎,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的命锄。 我是一名探鬼主播堰乔,決...
    沈念sama閱讀 41,010評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼脐恩!你這毒婦竟也來了镐侯?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,924評論 0 277
  • 序言:老撾萬榮一對情侶失蹤被盈,失蹤者是張志新(化名)和其女友劉穎析孽,沒想到半個(gè)月后搭伤,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體只怎,經(jīng)...
    沈念sama閱讀 46,469評論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,552評論 3 342
  • 正文 我和宋清朗相戀三年怜俐,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了身堡。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,680評論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡拍鲤,死狀恐怖贴谎,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情季稳,我是刑警寧澤擅这,帶...
    沈念sama閱讀 36,362評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站景鼠,受9級特大地震影響仲翎,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,037評論 3 335
  • 文/蒙蒙 一溯香、第九天 我趴在偏房一處隱蔽的房頂上張望鲫构。 院中可真熱鬧,春花似錦玫坛、人聲如沸结笨。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽炕吸。三九已至,卻和暖如春勉痴,著一層夾襖步出監(jiān)牢的瞬間算途,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評論 1 274
  • 我被黑心中介騙來泰國打工蚀腿, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留嘴瓤,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 49,099評論 3 378
  • 正文 我出身青樓莉钙,卻偏偏與公主長得像廓脆,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子磁玉,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,691評論 2 361

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