UIPicker bottom popup?

Is a UIPicker that appears from the bottom of the screen when an action is called only by a basic UIPickerView that is coordinated in a certain way? (How is a UIActionSheet?) How would I implement this?

+3
source share
4 answers

Here's the animation code I use:

- (void)animateDatePicker:(BOOL)show {
    CGRect screenRect = self.frame;
    CGSize pickerSize = [self.datePickerView sizeThatFits:CGSizeZero];
    CGRect startRect = CGRectMake(0.0,
                                  screenRect.origin.y + screenRect.size.height,
                                  pickerSize.width, pickerSize.height);

    CGRect pickerRect = CGRectMake(0.0,
                                   screenRect.origin.y + screenRect.size.height - pickerSize.height,
                                   pickerSize.width,
                                   pickerSize.height);

    self.datePickerView.frame = pickerRect;
    self.backgroundColor = UIColorMakeRGBA( 64, 64, 64, 0.7f - (int)show * 0.7f );

    if ( show ) {
        self.datePickerView.frame = startRect;
        [self.parentViewController addSubviewToWindow:self];
    }

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3f];
    [UIView setAnimationDelegate:self];

    self.backgroundColor = UIColorMakeRGBA( 64, 64, 64, 0.0f + (int)show * 0.7f );

    if ( show ) {
        self.datePickerView.frame = pickerRect;
    } else {
        [UIView setAnimationDidStopSelector:@selector(slideDownDidStop)];
        self.datePickerView.frame = startRect;
    }

    [UIView commitAnimations];  
}

datePickerView is a view that contains DatePicker:

self.datePickerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 174.0, 320.0, 286.0)];
self.datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0.0, 70.0, 320.0, 216.0)];
[self.datePicker setDatePickerMode:UIDatePickerModeDate];
[self.datePicker addTarget:self action:@selector(pickerValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.datePickerView addSubview:self.datePicker];

parentViewController must implement the addSubviewToWindow method:

- (void)addSubviewToWindow:(UIView *)addView {
    [self.view addSubview:addView];
}

UIColorMakeRGBA:

#define UIColorMakeRGBA(nRed, nGreen, nBlue, nAlpha) [UIColor colorWithRed:(nRed)/255.0f green:(nGreen)/255.0f blue:(nBlue)/255.0f alpha:nAlpha]

slideDownDidStop is a method that will be called after datePicker goes down successfully.

So, just to summarize - you have a MyViewController that has

MyDatePickerView *myDatePicker;

field.

MyDatePickerView - , datePicker UIDatePicker *, MyViewController * parentViewController animateDatePicker.

MyViewController (, UIControlEventTouchUpInside ),

[myDatePicker animateDatePicker:YES];

, , .

UPDATE: .

+4

UIPickerView UIViewController ( PopupUIPicker), :

PopupUIPicker *pickerController = [[[PopupUIPicker alloc] init] autorelease];
[currentViewController presentModalViewController:pickerController animated:YES];

currentViewController - , . :

[currentViewController dismissModalViewControllerAnimated:YES];

- . :

pickerController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
0

"UIPicker, "?

, Facebook, Three20, ( , , , ).

0

, Rob... UIPicker... ... , ... , ... ... ? ... iphone.

0

Source: https://habr.com/ru/post/1758761/


All Articles