IPhone, how can I reduce the font size in the buttons of worksheets?

I want the font size to be smaller for the text in the buttons of my action sheet, since my text is longer than the width.

How to reduce the font size?

I suggest that you can add things like collector views to action sheets that I might need to add my own buttons to the action sheet, if so, how?

I need an example.

EDIT: I’ve made some progress, but the actual button is not displayed, but you can see how it works with changing the text of the button when you click on it.

        UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Date Picker" 
                                                          delegate:self
                                                 cancelButtonTitle:@"Cancel"
                                            destructiveButtonTitle:nil
                                                 otherButtonTitles:@"OK",nil];    

        CGRect frame = CGRectMake(100.0, 80.0, 100.0, 40.0);

        UIButton *pickerView = [[UIButton alloc] initWithFrame:frame];

        [pickerView setTitle:@"FRED" forState:UIControlStateNormal];

        [pickerView setTitle:@"Go Back" forState:UIControlStateNormal];
        [pickerView setTitleColor:[UIColor blackColor] forState:UIControlEventTouchDown];
        pickerView.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        pickerView.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        //[removeButton addTarget:self action:@selector(buttonEvent:) forControlEvents:UIControlEventTouchDown];
        [pickerView setBackgroundColor:[UIColor blueColor]];


        [menu addSubview:pickerView];
        [menu showInView:self.view];        

        [pickerView release];
        [menu release];  
+3
source share
1 answer

, , , UIButtons, . , , subview UIActionSheet, , . , , , . ( ) UIDatePicker UIActionSheet. xib UIView.

UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDate;
[myUIActionSheet addSubview:pickerView];
[myUIActionSheet showInView:self.view];        
[myUIActionSheet setBounds:CGRectMake(0,0,320, myUIActionSheet.bounds.size.height + pickerView.bounds.size.height)];

CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = - pickerView.bounds.size.height; //you may need to change this offset
pickerView.bounds = pickerRect;

[pickerView release];
[myUIActionSheet release];

EDIT: subview xib, UIView xib UIView , . .

alt text

. - [myUIActionSheet.dismissWithClickedButtonIndex:0 animated:YES]; , , , , IIRC.

+3

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


All Articles