码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发中,MBProgressHUD提示自动换行

时间:2017-05-27 17:15:33      阅读:868      评论:0      收藏:0      [点我收藏+]

标签:fan   delay   地址   init   版本   import   clear   拖拽   bsp   

 1.首先,由于开发需要提示信息很多,无法显示完整,需求要求,显示完整,自动换行等功能;需要开发者自己重写三方的代码,代码如下:

第一步骤:

  你的工程中必须导入MBProgressHUD三方库,下载地址:https://github.com/jdg/MBProgressHUD

  当然这里也可以使用cocoapods进行集成第三方库,简单说一下步骤:

1.

  //可以采用拖拽文件的形式,将文件夹拖到Dos窗口下即可

  cd 工程路径

2.

  pod search 三方库名(复制需要的三方库版本)

3.

vim Podfile  在里面写入  

//这里8.0代表你的app最低支持的版本

platform :ios,8.0

target :工程名 do

pod ‘MBProgressHUD‘, ‘~> 0.9.2‘

end

 

4.

  sudo xcode-select --switch /Applications/Xcode.app

5.

  pod install - -verbose  - -no-repo-update 

   或者 : pod install 

 

第二步骤:导入三方库的头文件

  #import "MBProgressHUD.h"

 

第三步骤 : 如下代码

 

/*

含有时间,文字,图片提示框

适合多行文字显示

*/

- (void)showMessageTitle:(NSString *)title andDelay:(int)timeInt andImage:(NSString *)imageStr{

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];

    hud.userInteractionEnabled = YES;

    hud.backgroundColor = [UIColor clearColor];

    hud.animationType = MBProgressHUDAnimationZoomOut;

    hud.detailsLabelText = title;

    hud.square = NO;

    hud.mode = MBProgressHUDModeCustomView;

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];

    imageView.image = [UIImage imageNamed:imageStr];

    hud.customView = imageView;

    [hud hide:YES afterDelay:timeInt];

}

 

/*

含有时间,文字提示框

适合单行文字显示

*/

- (void)showMessageTitle:(NSString *)title andDelay:(int)timeInt{

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];

    hud.userInteractionEnabled = YES;

    hud.backgroundColor = [UIColor clearColor];

    hud.animationType = MBProgressHUDAnimationZoomOut;

    hud.detailsLabelText = title;

    hud.square = NO;

    hud.mode = MBProgressHUDModeText;

    [hud hide:YES afterDelay:timeInt];

}

 

运行结果如图:

技术分享 技术分享

 

 

iOS开发中,MBProgressHUD提示自动换行

标签:fan   delay   地址   init   版本   import   clear   拖拽   bsp   

原文地址:http://www.cnblogs.com/KennyHito/p/6913320.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!