当前位置 : 主页 > 手机开发 > ios >

iOS中 UIActionSheet字体的修改

来源:互联网 收集:自由互联 发布时间:2021-05-10
一,效果图。 二,代码。 RootViewController.h#import UIKit/UIKit.h@interface RootViewController : UIViewControllerUIActionSheetDelegate@endRootViewController.m-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UIActi

一,效果图。

二,代码。

RootViewController.h
#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController
<UIActionSheetDelegate>
@end

RootViewController.m

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"手机找回密码", nil];
  [actionSheet showInView:self.view];
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
  switch (buttonIndex) {
    case 0:
    {
      NSLog(@"--0--");
    }
      break;
    case 1:
    {
       NSLog(@"--1--");
    }
      break;
    default:
      break;
  }
}
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
  for (UIView *subViwe in actionSheet.subviews) {
    if ([subViwe isKindOfClass:[UIButton class]]) {
      UIButton *button = (UIButton*)subViwe;
      button.titleLabel.font=[UIFont systemFontOfSize:15];
      [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    }
  }
}

以上所述是小编给大家介绍的iOS中 UIActionSheet字体的修改,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对自由互联网站的支持!

网友评论