無標(biāo)題文章

- (void)createTopBtn{

? ? NSMutableArray *TopArr = [NSMutableArray arrayWithObjects:@"移動",@"傳媒",@"網(wǎng)工",@"軟工",@"游戲",@"+", nil];

? ? //創(chuàng)建循環(huán)按鈕

? ? for (int i = 0; i < TopArr.count; i++)

? ? {

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

? ? ? ? //設(shè)置按鈕顏色

? ? ? ? if (i == 0)

? ? ? ? {

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

? ? ? ? }

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

? ? ? ? {

? ? ? ? ? ? [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];

? ? ? ? ? ? [btn setTitleColor:[UIColor yellowColor] forState:UIControlStateSelected];

? ? ? ? ? ? btn.backgroundColor = [UIColor lightGrayColor];

? ? ? ? ? ? btn.titleLabel.font = [UIFont systemFontOfSize:26];

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

? ? ? ? ? ? btn.selected = NO;

? ? ? ? }

? ? ? ? else

? ? ? ? {

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

? ? ? ? }

? ? ? ? btn.frame = CGRectMake(i * 70, 64, 70, 50);

? ? ? ? btn.tag = 100+i;

? ? ? ? [btn setTitle:[TopArr objectAtIndex:i] forState:UIControlStateNormal];

? ? ? ? btn.backgroundColor = [UIColor whiteColor];

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

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

? ? }

}

- (void)MoveClick:(UIButton *)btn

{

? ? for (int i = 0; i<5; i++)

? ? {

? ? ? ? //根據(jù)tag獲取按鈕

? ? ? ? UIButton *btn1 = [self.view viewWithTag:100 + i];


? ? ? ? if (btn.tag == btn1.tag)

? ? ? ? {

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

? ? ? ? }

? ? ? ? else

? ? ? ? {

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

? ? ? ? }

? ? }

}


//創(chuàng)建滾動視圖

- (void)createScollView

{

? ? //創(chuàng)建滾動視圖 設(shè)置位置

? ? UIScrollView *bigScorllView? = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64+ 50, self.view.frame.size.width, self.view.frame.size.height - 64 - 50)];

? ? //設(shè)置偏移量

? ? bigScorllView.contentSize = CGSizeMake(self.view.frame.size.width *5, 0);

? ? //設(shè)置代理協(xié)議

? ? bigScorllView.delegate = self;

? ? bigScorllView.pagingEnabled = YES;

? ? //設(shè)置tag值

? ? bigScorllView.tag = 50;

? ? bigScorllView.backgroundColor = [UIColor yellowColor];

? ? [bigScorllView setContentOffset:CGPointMake(self.view.frame.size.width, 0)];

? ? [self.view addSubview:bigScorllView];

}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{

? ? if (scrollView.tag == 50)

? ? {

? ? ? ? //根據(jù)當(dāng)前視圖的偏移量設(shè)置當(dāng)前的按鈕位置

? ? ? ? for (int i=0; i<5; i++)

? ? ? ? {

? ? ? ? ? ? //根據(jù)tag獲取

? ? ? ? ? ? UIButton *btn1 = [self.view viewWithTag:100+i];

? ? ? ? ? ? if (scrollView.contentOffset.x/self.view.frame.size.width == (btn1.tag - 100))

? ? ? ? ? ? {

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

? ? ? ? ? ? }

? ? ? ? ? ? else

? ? ? ? ? ? {

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

? ? ? ? ? ? }

? ? ? ? }

? ? }

}




- (void)addClick:(UIButton *)sender


{

? ? if (sender.tag == 105) {

? ? ? ? if (sender.selected == YES) {

? ? ? ? ? ? sender.selected = NO;

? ? ? ? ? ? view1.hidden = YES;

? ? ? ? }

? ? ? ? else{

? ? ? ? ? ? sender.selected = YES;

? ? ? ? ? ? view1.hidden = NO;

? ? ? ? }

? ? }

}

//數(shù)據(jù)源方法

//默認(rèn)1組

//行數(shù)

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


? ? return 3;

}

//設(shè)置單元格 cell

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


? ? //根據(jù)可重用標(biāo)識符查找cell

? ? UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];

? ? //設(shè)置cell內(nèi)容

? ? NSArray *arr = @[@"確定添加",@"確定刪除",@"關(guān)閉"];



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


? ? cell.backgroundColor = [UIColor greenColor];


? ? return cell;


}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{



? ? if (indexPath.row == 2)

? ? {

? ? ? ? view1.hidden = YES;

? ? }

? ? else if (indexPath.row == 0)

? ? {

? ? ? ? UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"確認(rèn)添加" message:@"操作已成功" preferredStyle:UIAlertControllerStyleAlert];



? ? ? ? UIAlertAction *action = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {


? ? ? ? }];

? ? ? ? ? ? [alert addAction:action];


? ? ? ? ? ? [self.navigationController presentViewController:alert animated:YES completion:^{


? ? ? ? ? ? }];

? ? }

? ? else

? ? {

? ? ? ? UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"確認(rèn)刪除" message:@"操作已成功" preferredStyle:UIAlertControllerStyleAlert];



? ? ? ? UIAlertAction *action = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {


? ? ? ? }];


? ? ? ? [alert addAction:action];


? ? ? ? [self.navigationController presentViewController:alert animated:YES completion:^{


? ? ? ? }];

? ? }

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末夭禽,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌才顿,老刑警劉巖活烙,帶你破解...
    沈念sama閱讀 218,607評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件属愤,死亡現(xiàn)場離奇詭異揍诽,居然都是意外死亡愉适,警方通過查閱死者的電腦和手機犯助,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,239評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來维咸,“玉大人剂买,你說我怎么就攤上這事“┍停” “怎么了瞬哼?”我有些...
    開封第一講書人閱讀 164,960評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長租副。 經(jīng)常有香客問我坐慰,道長,這世上最難降的妖魔是什么附井? 我笑而不...
    開封第一講書人閱讀 58,750評論 1 294
  • 正文 為了忘掉前任讨越,我火速辦了婚禮,結(jié)果婚禮上永毅,老公的妹妹穿的比我還像新娘把跨。我一直安慰自己,他們只是感情好沼死,可當(dāng)我...
    茶點故事閱讀 67,764評論 6 392
  • 文/花漫 我一把揭開白布着逐。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪耸别。 梳的紋絲不亂的頭發(fā)上健芭,一...
    開封第一講書人閱讀 51,604評論 1 305
  • 那天,我揣著相機與錄音秀姐,去河邊找鬼慈迈。 笑死,一個胖子當(dāng)著我的面吹牛省有,可吹牛的內(nèi)容都是我干的痒留。 我是一名探鬼主播,決...
    沈念sama閱讀 40,347評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼蠢沿,長吁一口氣:“原來是場噩夢啊……” “哼伸头!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起舷蟀,我...
    開封第一講書人閱讀 39,253評論 0 276
  • 序言:老撾萬榮一對情侶失蹤恤磷,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后野宜,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體扫步,經(jīng)...
    沈念sama閱讀 45,702評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,893評論 3 336
  • 正文 我和宋清朗相戀三年匈子,在試婚紗的時候發(fā)現(xiàn)自己被綠了锌妻。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,015評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡旬牲,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出搁吓,到底是詐尸還是另有隱情原茅,我是刑警寧澤,帶...
    沈念sama閱讀 35,734評論 5 346
  • 正文 年R本政府宣布堕仔,位于F島的核電站擂橘,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏摩骨。R本人自食惡果不足惜通贞,卻給世界環(huán)境...
    茶點故事閱讀 41,352評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望恼五。 院中可真熱鬧昌罩,春花似錦、人聲如沸灾馒。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,934評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至轨功,卻和暖如春旭斥,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背古涧。 一陣腳步聲響...
    開封第一講書人閱讀 33,052評論 1 270
  • 我被黑心中介騙來泰國打工垂券, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人羡滑。 一個月前我還...
    沈念sama閱讀 48,216評論 3 371
  • 正文 我出身青樓菇爪,卻偏偏與公主長得像,于是被迫代替她去往敵國和親啄栓。 傳聞我的和親對象是個殘疾皇子娄帖,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,969評論 2 355

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