iOS開發中,MBProgressHUD提示自動換行

來源:互聯網
上載者:User

標籤: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提示自動換行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.