UIActionSheet

//#pragma SegmentedControlAction  觸發事件: 選擇不同的段,滑動到不同位置
//
//-(void)segmentedControlAction:(UISegmentedControl *)segmentedControl
//{
//
//    float x = segmentedControl.selectedSegmentIndex * CGRectGetWidth(_bgScrollView.frame);
//    CGRect rect = CGRectMake(x, 0, CGRectGetWidth(_bgScrollView.frame), CGRectGetHeight(_bgScrollView.frame));
//    [_bgScrollView scrollRectToVisible:rect animated:YES];
//
//    [UIView animateWithDuration:0.3 animations:^{
//
//        float orginX = segmentedControl.selectedSegmentIndex == 0 ? 0:IPHONE_WIDTH/2;
//        _moveLabel.origin = CGPointMake(orginX, _moveLabel.origin.y);
//
//
//    }];
//
//}




- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
    NSArray *subViews = actionSheet.subviews;
    
    
    for (UIView *subViwe in actionSheet.subviews) {
        
        if ([subViwe isKindOfClass:[UIButton class]]) {
            UIButton *button = (UIButton*)subViwe;
            
            if ([button.titleLabel.text isEqualToString:@"取消"]) {
                
               [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                [button setBackgroundImage:[UIImage imageWithColor:[UIColor redColor]] forState:UIControlStateSelected];

            }else{
                [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
                [button setBackgroundImage:[UIImage imageWithColor:kBtnNomalColor] forState:UIControlStateSelected];
                [button setBackgroundImage:[UIImage imageWithColor:[UIColor lightGrayColor]] forState:UIControlStateNormal];
            }
        }
    }
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = kViewBackColor;
    [_navView setTitle:@"隨訪問卷" withRightText:@"新建"];
    
        _segmentedCtrl = [[UISegmentedControl alloc] initWithItems:@[@"問卷",@"題目"]];
        _segmentedCtrl.frame = CGRectMake(0, kNavBottomY, IPHONE_WIDTH, kBtnHeight);
        _segmentedCtrl.tintColor = [UIColor whiteColor];
        _segmentedCtrl.backgroundColor = [UIColor whiteColor];
        _segmentedCtrl.momentary = YES;
        _segmentedCtrl.multipleTouchEnabled = NO;
        [_segmentedCtrl addTarget:self action:@selector(segmentedControlAction:) forControlEvents:UIControlEventValueChanged];
        [_segmentedCtrl setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor],NSFontAttributeName:kLableFont} forState:UIControlStateNormal];
        [_segmentedCtrl setTitleTextAttributes:@{NSForegroundColorAttributeName:kBtnNomalColor,NSFontAttributeName:kLableFont} forState:UIControlStateSelected];
    
        _segmentedCtrl.segmentedControlStyle = UISegmentedControlStylePlain;
        _segmentedCtrl.selectedSegmentIndex = 0;
        [self.view addSubview:_segmentedCtrl];
    
    [self createUI];
    
    _questionSheet = [[UIActionSheet alloc]
                                  initWithTitle:nil
                                  delegate:self
                                  cancelButtonTitle:@"取消"
                                  destructiveButtonTitle:@"單選題"
                                  otherButtonTitles:@"多選題", @"數字填空題",@"文本填空題",@"日期",@"時間",nil];
    _questionSheet.actionSheetStyle = UIActionSheetStyleDefault;
    _questionSheet.backgroundColor = [UIColor whiteColor];
    
    
    
}





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章