2015-11-23 4 views
1

je dois définir la taille UIActionSheet titre "Sélectionnez l'option pour copier"définir la taille de la police à titre UIActionSheet

enter image description here

avec ce code:

[[UIActionSheet alloc] initWithTitle:@"Select option to copy:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil 
            otherButtonTitles:@"copy all ",nil]; 
+0

Qu'avez-vous essayé? Comment créez-vous cette feuille d'action? Montrez-nous du code;) – KerrM

Répondre

3

Vous pourriez tirer parti de Propriétés d'exécution pour définir la police. En utilisant NSAttributedString, vous pouvez y parvenir.

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil 
            otherButtonTitles:@"copy all ",nil]; 

//Creating Attributed String with System Font size of 30.0f 
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"Select option to copy:" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:30.0f]}]; 

//Accessing the Alert View Controller property from Action Sheet 
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"]; 

//Setting Attributed Title property of Alert View Controller 
[alertController setValue:attrString forKey:@"_attributedTitle"]; 

//Displaying the Action Sheet 
[actionSheet showInView:self.view]; 

enter image description here

+0

Comment puis-je changer la taille de la police des boutons bleus? –

+1

@RoeiNadam Il n'y a pas d'API pour modifier les polices pour les boutons d'action à l'intérieur de la feuille d'action. trouver une solution pour cela –

+0

Ok, il comprend la couleur du titre du bouton? –

0

Vous pouvez changer la police de titre de uiactionsheet en utilisant ce delgate

-(void)willPresentActionSheet:(UIActionSheet *)actionSheet { 
     for (UIView *_currentView in actionSheet.subviews) { 
      if ([_currentView isKindOfClass:[UILabel class]]) { 
       UILabel *l = [[UILabel alloc] initWithFrame:_currentView.frame]; 
       l.text = [(UILabel *)_currentView text]; 
       [l setFont:[UIFont fontWithName:@"Arial-BoldMT" size:20]]; 
       l.textColor = [UIColor darkGrayColor]; 
       l.backgroundColor = [UIColor clearColor]; 
       [l sizeToFit]; 
       [l setCenter:CGPointMake(actionSheet.center.x, 25)]; 
       [l setFrame:CGRectIntegral(l.frame)]; 
       [actionSheet addSubview:l]; 
       _currentView.hidden = YES; 
       break; 
      } 
     } 
    } 
+0

il ne change pas la taille) -; J'ai ajouté la question –

+0

qui ios version 7 ou 8? – AnshaD

+0

dans iOS 9 ne fonctionne pas –