查看: 2664|回复: 0

[IOS开发教程] iOS中 UIActionSheet字体的修改

发表于 2017-8-2 08:00:02
太阳http代理AD

一,效果图。

二,代码。

  1. RootViewController.h
  2. #import <UIKit/UIKit.h>
  3. @interface RootViewController : UIViewController
  4. <UIActionSheetDelegate>
  5. @end
  6. RootViewController.m
  7. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  8. {
  9. UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"手机找回密码", nil];
  10. [actionSheet showInView:self.view];
  11. }
  12. #pragma mark - UIActionSheetDelegate
  13. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  14. {
  15. switch (buttonIndex) {
  16. case 0:
  17. {
  18. NSLog(@"--0--");
  19. }
  20. break;
  21. case 1:
  22. {
  23. NSLog(@"--1--");
  24. }
  25. break;
  26. default:
  27. break;
  28. }
  29. }
  30. - (void)willPresentActionSheet:(UIActionSheet *)actionSheet
  31. {
  32. for (UIView *subViwe in actionSheet.subviews) {
  33. if ([subViwe isKindOfClass:[UIButton class]]) {
  34. UIButton *button = (UIButton*)subViwe;
  35. button.titleLabel.font=[UIFont systemFontOfSize:15];
  36. [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  37. }
  38. }
  39. }
复制代码

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



太阳http代理AD
回复

使用道具 举报