最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

IOS 仿Android吐司提示框的實例(分享)

 更新時間:2017年12月20日 10:14:45   作者:鍵盤舞者113  
下面小編就為大家分享一篇IOS 仿Android吐司提示框的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

直接上代碼

#import <UIKit/UIKit.h>
@interface ShowToastView : UIView
+(void)showToastView:(UIView *)uiview WithMessage:(NSString *)message;

+(void)showToastViewShort:(UIView *)uiview WithMessage:(NSString *)message;

+(void)showToastViewWithCostUpload:(UIView *)uiview WithMessage:(NSString *)message;

+(void)showSmallHeightToastView:(UIView *)uiview WithMessage:(NSString *)message;
@end
#import "ShowToastView.h"
@implementation ShowToastView
//Toast提示框
+(void)showToastView:(UIView *)uiview WithMessage:(NSString *)message
{
  UIView *showview = [[UIView alloc]init];
  showview.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.3];
  showview.frame = CGRectMake(1, 1, 1, 1);
  showview.layer.cornerRadius = 5.0f;
  showview.layer.masksToBounds = YES;
  [uiview addSubview:showview];
  UILabel *label = [[UILabel alloc]init];
  CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
  label.frame = CGRectMake(10, 5, LabelSize.width, LabelSize.height);
  label.text = message;
  label.textColor = [UIColor whiteColor];
  label.textAlignment = 1;
  label.backgroundColor = [UIColor clearColor];
  label.font = [UIFont boldSystemFontOfSize:font(15)];
  [showview addSubview:label];
  showview.frame = CGRectMake((uiview.frame.size.width - LabelSize.width - 20)/2, uiview.frame.size.height - LabelSize.height-100, LabelSize.width+20, LabelSize.height+10);
  [UIView animateWithDuration:5.0 animations:^{
    showview.alpha = 0;
  } completion:^(BOOL finished) {
    [showview removeFromSuperview];
  }];
}
+(void)showToastViewShort:(UIView *)uiview WithMessage:(NSString *)message
{
  UIView *showview = [[UIView alloc]init];
  showview.backgroundColor = [UIColor whiteColor];
  showview.frame = CGRectMake(1, 1, 1, 1);
  showview.layer.cornerRadius = 5.0f;
  showview.layer.masksToBounds = YES;
  [uiview addSubview:showview];
  UILabel *label = [[UILabel alloc]init];
  CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
  label.frame = CGRectMake(10, 5, LabelSize.width, LabelSize.height);
  label.text = message;
  label.textColor = [UIColor blackColor];
  label.textAlignment = 1;
  label.backgroundColor = [UIColor clearColor];
  label.font = [UIFont boldSystemFontOfSize:15];
  [showview addSubview:label];
  showview.frame = CGRectMake((uiview.frame.size.width - LabelSize.width - 20)/2, uiview.frame.size.height - LabelSize.height-60, LabelSize.width+20, LabelSize.height+10);
  [UIView animateWithDuration:1 animations:^{
    showview.alpha = 0;
  } completion:^(BOOL finished) {
    [showview removeFromSuperview];
  }];
}
//費用提報的Toast位置往上放一點
+(void)showToastViewWithCostUpload:(UIView *)uiview WithMessage:(NSString *)message
{
  UIView *showview = [[UIView alloc]init];
  showview.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.3];
  showview.frame = CGRectMake(1, 1, 1, 1);
  showview.layer.cornerRadius = 5.0f;
  showview.layer.masksToBounds = YES;
  [uiview addSubview:showview];
  UILabel *label = [[UILabel alloc]init];
  CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
  label.frame = CGRectMake(10, 5, LabelSize.width, LabelSize.height);
  label.text = message;
  label.textColor = [UIColor whiteColor];
  label.textAlignment = 1;
  label.backgroundColor = [UIColor clearColor];
  label.font = [UIFont boldSystemFontOfSize:font(15)];
  [showview addSubview:label];
  showview.frame = CGRectMake((uiview.frame.size.width - LabelSize.width - 20)/2, uiview.frame.size.height - LabelSize.height-100, LabelSize.width+20, LabelSize.height+10);
  [UIView animateWithDuration:3.0 animations:^{
    showview.alpha = 0;
  } completion:^(BOOL finished) {
    [showview removeFromSuperview];
  }];
}
//點擊開始按鈕的時候提示沒有任務(wù),但是由于字數(shù)太多,高度又和寬度有一定的對比,所以在這里改成小一點高度
+(void)showSmallHeightToastView:(UIView *)uiview WithMessage:(NSString *)message
{
  UIView *showview = [[UIView alloc]init];
  showview.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.3];
  showview.frame = CGRectMake(1, 1, 1, 1);
  showview.layer.cornerRadius = 5.0f;
  showview.layer.masksToBounds = YES;
  [uiview addSubview:showview];
  UILabel *label = [[UILabel alloc]init];
  CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
  label.frame = CGRectMake(10, 0, LabelSize.width, LabelSize.height);
  label.text = message;
  label.textColor = [UIColor whiteColor];
  label.textAlignment = 1;
  label.backgroundColor = [UIColor clearColor];
  label.font = [UIFont boldSystemFontOfSize:font(15)];
  [showview addSubview:label];
  showview.frame = CGRectMake((uiview.frame.size.width - LabelSize.width - 20)/2, uiview.frame.size.height - LabelSize.height-60, LabelSize.width+20, LabelSize.height-5);
  [UIView animateWithDuration:5.0 animations:^{
    showview.alpha = 0;
  } completion:^(BOOL finished) {
    [showview removeFromSuperview];
  }];
}

@end

使用方法

[ShowToastView showToastView:self.view WithMessage:@"用戶名或密碼錯誤"];

以上這篇IOS 仿Android吐司提示框的實例(分享)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS實現(xiàn)短信驗證碼倒計時

    iOS實現(xiàn)短信驗證碼倒計時

    這篇文章主要介紹了iOS實現(xiàn)短信驗證碼倒計時功能,一種方法是利用NSTimer計時器,另一種方法是利用GCD實現(xiàn)短信驗證碼倒計時,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • iOS中利用CoreAnimation實現(xiàn)一個時間的進度條效果

    iOS中利用CoreAnimation實現(xiàn)一個時間的進度條效果

    在iOS中實現(xiàn)進度條通常都是通過不停的設(shè)置progress來完成的,這樣的進度條適用于網(wǎng)絡(luò)加載(上傳下載文件、圖片等)。下面通過本文給大家介紹iOS中利用CoreAnimation實現(xiàn)一個時間的進度條,需要的的朋友參考下吧
    2017-09-09
  • iOS10全新推送功能實現(xiàn)代碼

    iOS10全新推送功能實現(xiàn)代碼

    這篇文章主要為大家詳細介紹了iOS10全新推送功能實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • Xcode 8打印log日志的問題小結(jié)及解決方法

    Xcode 8打印log日志的問題小結(jié)及解決方法

    這篇文章主要介紹了Xcode 8打印log日志的問題小結(jié)及解決方法的相關(guān)資料,非常不錯具有參考借鑒價值,需要的朋友可以參考下
    2016-09-09
  • IOS Xib控件拖拽與頁面跳轉(zhuǎn)實例

    IOS Xib控件拖拽與頁面跳轉(zhuǎn)實例

    下面小編就為大家分享一篇IOS Xib控件拖拽與頁面跳轉(zhuǎn)實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • iOS應(yīng)用開發(fā)中視圖控件UIWindow的基本使用教程

    iOS應(yīng)用開發(fā)中視圖控件UIWindow的基本使用教程

    這篇文章主要介紹了iOS應(yīng)用開發(fā)中視圖控件UIWindow的基本使用教程,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2016-02-02
  • IOS 基礎(chǔ)之nil,NULL,NSNULL區(qū)別詳解

    IOS 基礎(chǔ)之nil,NULL,NSNULL區(qū)別詳解

    這篇文章主要介紹了IOS 基礎(chǔ)之nil,NULL,NSNULL區(qū)別詳解的相關(guān)資料,需要的朋友可以參考下
    2017-04-04
  • iOS實現(xiàn)圖片輪播器

    iOS實現(xiàn)圖片輪播器

    這篇文章主要為大家詳細介紹了iOS如何實現(xiàn)圖片輪播器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-02-02
  • iOS中利用CAEmitterLayer實現(xiàn)粒子動畫詳解

    iOS中利用CAEmitterLayer實現(xiàn)粒子動畫詳解

    粒子效果應(yīng)該對現(xiàn)在很多人來說并不陌生,我們之前也分享了一些相關(guān)文章,下面這篇文章主要給大家介紹了關(guān)于iOS中利用CAEmitterLayer實現(xiàn)粒子動畫的相關(guān)資料,文中介紹的非常詳細,需要的朋友們下面來一起看看吧。
    2017-06-06
  • iOS DispatchSourceTimer 定時器的具體使用

    iOS DispatchSourceTimer 定時器的具體使用

    定時器在很多地方都可以用到,本文主要介紹了iOS DispatchSourceTimer 定時器的具體使用,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-05-05

最新評論

宿州市| 宁津县| 赞皇县| 雅安市| 马鞍山市| 阜新| 宜阳县| 丁青县| 松溪县| 江永县| 固安县| 临澧县| 西贡区| 连平县| 建昌县| 米林县| 新乡市| 新营市| 安陆市| 太谷县| 金昌市| 开化县| 易门县| 同仁县| 同江市| 运城市| 宁化县| 和田县| 景德镇市| 永定县| 长岭县| 英吉沙县| 开封市| 大化| 华亭县| 澄江县| 嘉禾县| 诸城市| 乌什县| 墨江| 木兰县|