欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

直接上代碼

#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];
  }];
}
//費(fèi)用提報(bào)的Toast位置往上放一點(diǎn)
+(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];
  }];
}
//點(diǎn)擊開始按鈕的時(shí)候提示沒有任務(wù),但是由于字?jǐn)?shù)太多,高度又和寬度有一定的對比,所以在這里改成小一點(diǎn)高度
+(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:@"用戶名或密碼錯(cuò)誤"];

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

相關(guān)文章

  • iOS開發(fā)技巧之WeakSelf宏的進(jìn)化詳解

    iOS開發(fā)技巧之WeakSelf宏的進(jìn)化詳解

    在程序中我們經(jīng)常用到Block,但寫weak self 時(shí)會(huì)比較繁瑣,下面這篇文章主要給大家介紹了關(guān)于iOS開發(fā)技巧之WeakSelf宏的進(jìn)化的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們一起來看看吧
    2018-05-05
  • iOS開發(fā)frame和bounds使用示例詳解

    iOS開發(fā)frame和bounds使用示例詳解

    這篇文章主要為大家介紹了iOS開發(fā)frame和bounds使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • iOS11 WKWebView問題匯總

    iOS11 WKWebView問題匯總

    本文給大家分享的是作者在IOS11中使用WKWebView加載URL出現(xiàn)無法加載內(nèi)容的情況的解決方法,有同樣問題的小伙伴可以查看下
    2017-11-11
  • 基于UIControl控件實(shí)現(xiàn)ios點(diǎn)贊功能

    基于UIControl控件實(shí)現(xiàn)ios點(diǎn)贊功能

    在開發(fā)當(dāng)中,可能很多時(shí)候都需要做個(gè)點(diǎn)贊的需求,如果用按鈕實(shí)現(xiàn),按鈕作為一個(gè)系統(tǒng)復(fù)合控件,外部是一個(gè) View--》UIControl的容器,本文給大家分享一個(gè)基于UIControl控件實(shí)現(xiàn)ios點(diǎn)贊功能,需要的朋友可以參考下
    2015-09-09
  • iOS仿支付寶芝麻信用分?jǐn)?shù)儀表盤動(dòng)畫效果

    iOS仿支付寶芝麻信用分?jǐn)?shù)儀表盤動(dòng)畫效果

    這篇文章主要為大家詳細(xì)介紹了iOS仿支付寶芝麻信用分?jǐn)?shù)儀表盤動(dòng)畫效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • iOS 委托與文本輸入(內(nèi)容根據(jù)iOS編程編寫)

    iOS 委托與文本輸入(內(nèi)容根據(jù)iOS編程編寫)

    這篇文章主要介紹了iOS 委托與文本輸入(內(nèi)容根據(jù)iOS編程編寫) 的相關(guān)資料,需要的朋友可以參考下
    2016-09-09
  • iOS錄屏和截屏監(jiān)聽的實(shí)現(xiàn)代碼

    iOS錄屏和截屏監(jiān)聽的實(shí)現(xiàn)代碼

    本篇文章主要介紹了iOS錄屏和截屏監(jiān)聽的實(shí)現(xiàn)代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-05-05
  • 簡單介紹iOS開發(fā)中關(guān)于category的應(yīng)用

    簡單介紹iOS開發(fā)中關(guān)于category的應(yīng)用

    這篇文章主要介紹了iOS開發(fā)中關(guān)于category的應(yīng)用,代碼仍然基于傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2015-09-09
  • IOS使用NSUserDefault去實(shí)現(xiàn)界面?zhèn)髦岛蛿?shù)據(jù)存儲(chǔ)

    IOS使用NSUserDefault去實(shí)現(xiàn)界面?zhèn)髦岛蛿?shù)據(jù)存儲(chǔ)

    這篇文章主要介紹了IOS使用NSUserDefault去實(shí)現(xiàn)界面?zhèn)髦岛蛿?shù)據(jù)存儲(chǔ)的相關(guān)資料,需要的朋友可以參考下
    2017-07-07
  • iOS開發(fā)定時(shí)器的三種方法分享

    iOS開發(fā)定時(shí)器的三種方法分享

    相信在大家開發(fā)過程中,常常需要在某個(gè)時(shí)間后執(zhí)行某個(gè)方法,或者是按照某個(gè)周期一直執(zhí)行某個(gè)方法。在這個(gè)時(shí)候,我們就需要用到定時(shí)器。然而,在iOS中有很多方法完成以上的任務(wù),到底有多少種方法呢?下面就通過這篇文章來一起學(xué)習(xí)學(xué)習(xí)吧。
    2016-09-09

最新評論