91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

iphone下類似anroid的toast類 吐司提示

發布時間:2020-06-28 16:59:43 來源:網絡 閱讀:525 作者:yvbang 欄目:開發技術

 h:

 

#import <UIKit/UIKit.h>

#define RGB(a, b, c) [UIColor colorWithRed:(a / 255.0f) green:(b / 255.0f) blue:(c / 255.0f) alpha:1.0f]

#define RGBA(a, b, c, d) [UIColor colorWithRed:(a / 255.0f) green:(b / 255.0f) blue:(c / 255.0f) alpha:d]

@interface MyToast : UIView

+ (void)showWithText:(NSString *)text:(int)toastY;

+ (void)showWithImage:(UIImage *)p_w_picpath;

@end

 

 m:

 

#import "MyToast.h"

#import <QuartzCore/QuartzCore.h>

@implementation MyToast

- (void)__show {

    [UIView beginAnimations:@"show" context:nil];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDuration:0.2f];

    [UIView setAnimationDidStopSelector:@selector(__animationDidStop:__finished:__context:)];

    self.alpha = 1.0f;

    [UIView commitAnimations];

}

- (void)__hide {

    [self performSelectorOnMainThread:@selector(__hideThread) withObject:nil waitUntilDone:NO];

}

- (void)__hideThread {

    [UIView beginAnimations:@"hide" context:nil];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDuration:0.8f];

    [UIView setAnimationDidStopSelector:@selector(__animationDidStop:__finished:__context:)];

    self.alpha = 0.0f;

    [UIView commitAnimations];

}

- (void)__animationDidStop:(NSString *)animationID __finished:(NSNumber *)finished __context:(void *)context {

    if ([animationID isEqualToString:@"hide"]) {

        [self removeFromSuperview];

        self = nil;

    }

    else if ([animationID isEqualToString:@"show"]) {

        [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(__hide) userInfo:nil repeats:NO];

    }

}

+ (MyToast *)__createWithText:(NSString *)text:(int)toastY {

    float screenWidth = [UIScreen mainScreen].bounds.size.width;

//    float screenHeight = [UIScreen mainScreen].bounds.size.height;

    float x = 10.0f;

    float width = screenWidth - x * 2.0f;

    

    UILabel *textLabel = [[UILabel alloc] init];

    textLabel.backgroundColor = [UIColor clearColor];

    textLabel.textAlignment = UITextAlignmentCenter;

    textLabel.font = [UIFont systemFontOfSize:14];

    textLabel.textColor = RGB(255, 255, 255);

    textLabel.numberOfLines = 0;

    textLabel.lineBreakMode = UILineBreakModeCharacterWrap;

    CGSize sz = [text sizeWithFont:textLabel.font

                 constrainedToSize:CGSizeMake(width - 20.0f, 9999.0f)

                     lineBreakMode:textLabel.lineBreakMode];

    

    CGRect tmpRect;

    tmpRect.size.width = width;

    tmpRect.size.height = MAX(sz.height + 20.0f, 38.0f);

    tmpRect.origin.x = floor((screenWidth - width) / 2.0f);

    tmpRect.origin.y =toastY;// floor(screenHeight - tmpRect.size.height - 15.0f);

    

    MyToast *toast = [[MyToast alloc] initWithFrame:tmpRect];

    toast.backgroundColor = RGBA(0, 0, 0, 0.8f);

    CALayer *layer = toast.layer;

    layer.masksToBounds = YES;

    layer.cornerRadius = 5.0f;

    

    textLabel.text = text;

    tmpRect.origin.x = floor((toast.frame.size.width - sz.width) / 2.0f);

    tmpRect.origin.y = floor((toast.frame.size.height - sz.height) / 2.0f);

    tmpRect.size = sz;

    textLabel.frame = tmpRect;

    [toast addSubview:textLabel];

    [textLabel release];

    toast.alpha = 0.0f;

    

    return toast;

}

+ (MyToast *)__createWithImage:(UIImage *)p_w_picpath {

    float screenWidth = [UIScreen mainScreen].bounds.size.width;

    float screenHeight = [UIScreen mainScreen].bounds.size.height;

    float x = 10.0f;

    float width = screenWidth - x * 2.0f;

    

    UIImageView *p_w_picpathView = [[UIImageView alloc] initWithImage:p_w_picpath];

    CGSize sz = p_w_picpathView.frame.size;

    

    CGRect tmpRect;

    tmpRect.size.width = width;

    tmpRect.size.height = MAX(sz.height + 20.0f, 38.0f);

    tmpRect.origin.x = floor((screenWidth - width) / 2.0f);

    tmpRect.origin.y = floor(screenHeight - tmpRect.size.height - 15.0f);

    

    MyToast *toast = [[MyToast alloc] initWithFrame:tmpRect];

    toast.backgroundColor = RGBA(0, 0, 0, 0.8f);

    CALayer *layer = toast.layer;

    layer.masksToBounds = YES;

    layer.cornerRadius = 5.0f;

    

    tmpRect.origin.x = floor((toast.frame.size.width - sz.width) / 2.0f);

    tmpRect.origin.y = floor((toast.frame.size.height - sz.height) / 2.0f);

    tmpRect.size = sz;

    p_w_picpathView.frame = tmpRect;

    [toast addSubview:p_w_picpathView];

    [p_w_picpathView release];

    toast.alpha = 0.0f;

    return toast;

}

/**

 * Show toast with text in application window

 * @param text Text to print in toast window

 */

+ (void)showWithText:(NSString *)text:(int)toastY {

    MyToast *toast = [MyToast __createWithText:text:toastY];

    

    UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];

    [mainWindow addSubview:toast];

    [toast release];

    

    [toast __show];

}

/**

 * Show toast with p_w_picpath in application window

 * @param p_w_picpath Image to show in toast window

 */

+ (void)showWithImage:(UIImage *)p_w_picpath {

    MyToast *toast = [MyToast __createWithImage:p_w_picpath];

    UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];

    [mainWindow addSubview:toast];

    [toast release];

    [toast __show];

}@end

 


引用:

 

 

#import "MyToast.h"

 

[MyToast showWithText:@"這里還什么都沒有哦 親!":380];

 

 

數字是顯示的Y坐標。

 

 

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

常山县| 庄河市| 义马市| 玉树县| 芜湖县| 武乡县| 秀山| 临清市| 张家港市| 福泉市| 霞浦县| 民丰县| 乌审旗| 阿克苏市| 桃源县| 馆陶县| 沈丘县| 额敏县| 安远县| 冷水江市| 乌鲁木齐市| 钟祥市| 伊川县| 都匀市| 潞西市| 新邵县| 平湖市| 滨海县| 太白县| 达州市| 洪泽县| 凌源市| 墨竹工卡县| 长顺县| 黄浦区| 乌兰浩特市| 香港| 贡山| 金沙县| 怀化市| 独山县|