大佬教程收集整理的这篇文章主要介绍了如何在ios中的UIAlertView上以普通字体显示所有按钮文本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
UIAlertView *alert = [[UIAlertView alloc]initWithtitle:@"test" message:@"testTestTest" delegate:Nil cancelButtontitle:nil otherButtontitles:@"first",@"second",@"third",nil]; [alert show];
我创建了UIAlertView的子类:
头文件:
#import <UIKit/UIKit.h> @interface MLKLoadingAlertView : UIAlertView - (id)initWithtitle:(NSString *)title; @end
实施档案:
#import "MLKLoadingAlertView.h" #define ACTIVITY_INDicATOR_CENTER CGPointMake(130,90) @implementation MLKLoadingAlertView - (id)initWithtitle:(NSString *)title { if ( self = [super init] ) { self.title = title; self.message = @"\n\n"; [self addButtonWithtitle:@"OK"]; [self addButtonWithtitle:@"Cancel"]; [self addButtonWithtitle:@"Sure"]; [self setDelegate:self]; } return self; } // You can Customise this based on your requirement by adding subviews. - (void)didPresentAlertView:(UIAlertView *)alertView { NSArray *subviews = [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController.view.subviews; if( subviews.count > 1 ) { // iOS while presenTing an alertview uses a presening view controller. That controller's view has several subviews. I have picked one // subview from it which has frame SIMILAR TO the alertview frame. UIView *presentedView = [subviews objectATindex:1]; for( UIView *view in presentedView.subviews ) { for( UIView *subView in view.subviews ) { if( [subView isKindOfClass:[UITableView class]] ) { NSInteger numberOfButtons = [(UITableView *)subView numberOfRowsInSection:0]; UITableViewCell *buttonCell = [(UITableView *)subView cellForRowATindexPath:[NSIndexPath indexPathForRow:numberOfButtons-1 inSection:0]]; for( UIView *cellSubView in buttonCell.contentView.subviews ) { if( [cellSubView isKindOfClass:[UILabel class]] ) { [(UILabel *)cellSubView setFont:[UIFont systemFontOfSize:17]]; } } break; } } } UIActivityInDicatorView *customActivityInDicator = [[UIActivityInDicatorView alloc] initWithActivityInDicatorStyle:UIActivityInDicatorViewStyleGray]; [customActivityInDicator startAnimaTing]; customActivityInDicator.center = ACTIVITY_INDicATOR_CENTER; [presentedView addSubview:customActivityInDicator]; } }
我在我的View Controller中创建了这个MLKLoadingAlertView的实例,如下所示:
@H_982_4@mLKLoadingAlertView *loadingAlertView = [[MLKLoadingAlertView alloc] initWithtitle@R_143_6964@]; [loadingAlertView show];使用这种方法我们可以实现两件事:
>我们可以在iOS 7中为UIAlertView添加子视图
>我们可以在iOS 7中更改按钮文本的字体
注意:此方法仅适用于iOS 7.
以上是大佬教程为你收集整理的如何在ios中的UIAlertView上以普通字体显示所有按钮文本全部内容,希望文章能够帮你解决如何在ios中的UIAlertView上以普通字体显示所有按钮文本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。