你好,歡迎來到IOS教程網

 Ios教程網 >> IOS訊息 >> 關於IOS >> block 滑塊導航條 關聯

block 滑塊導航條 關聯

編輯:關於IOS

@property(nonatomic,retain)UIView *block;

  -(void)btnClicked:(UIButton *)sender {      __block CGRect targetFrame = self.block.frame;     BOOLdirectionRight=targetFrame.origin.x<sender.frame.origin.x;     targetFrame.origin.x=sender.frame.origin.x+(directionRight?30:-30);       [UIView animateWithDuration:0.1 animations:^{         self.block.frame=targetFrame;     }completion:^(BOOL finished){         targetFrame.origin.x+=directionRight?-50:50;         [UIView animateWithDuration:0.1 animations:^{             self.block.frame=targetFrame;         }completion:^(BOOL finished){             targetFrame.origin.x+=directionRight?20:-20;             [UIView animateWithDuration:0.1 animations:^{                 self.block.frame=targetFrame;             }];         }];     }]; } -(void)buildLayout{    NSArray *arrbtn=@[@"主菜單",@"收藏",@"最近使用",@"更多。。。",];       self.view.backgroundColor=[UIColor colorWithRed:241/255.0fgreen:200/255.0f blue:55/255.0f alpha:1.0f];          for (int i=0; i<5; i++) {         UIButton *btn=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];         //[btn setTitle:[NSString stringWithFormat:@"btn%d",i]forState:UIControlStateNormal];         btn.frame=CGRectMake(64*i,CGRectGetHeight(self.view.bounds)-40, 64, 40);       [btn setTitle:[arrbtn objectAtIndex:i] forState:UIControlStateNormal];         btn.layer.backgroundColor=[UIColor clearColor].CGColor;         btn.layer.borderWidth=1.0f;         [btn addTarget:self action:@selector(btnClicked:)forControlEvents:UIControlEventTouchUpInside];         [self.view addSubview:btn];     }     UIView *blockBg=[[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetHeight(self.view.bounds)-60, 320, 20)];     blockBg.backgroundColor=[UIColor clearColor];     [self.view addSubview:blockBg];          UIView *bgLayer=[[UIView alloc]initWithFrame:blockBg.frame];     bgLayer.backgroundColor=[UIColor clearColor];     bgLayer.layer.opacity=0.4f;     [blockBg addSubview:bgLayer];          self.block=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 64,20)];     self.block.backgroundColor=[UIColor orangeColor];     self.block.layer.opacity=1.0f;     [blockBg addSubview:self.block];           }  
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved