iOS 简单提示view

+(void)showMessage:(NSString *)message
{
    UIWindow * window = [UIApplication sharedApplication].keyWindow;
    UIView *showview =  [[UIView alloc]init];
    showview.backgroundColor = [UIColor blackColor];
    showview.frame = CGRectMake(1, 1, 1, 1);
    showview.alpha = 1.0f;
    showview.layer.cornerRadius = 5.0f;
    showview.layer.masksToBounds = YES;
    [window 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 = NSTextAlignmentCenter;
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:13];
    [showview addSubview:label];
    showview.frame = CGRectMake((ScreenWidth - LabelSize.width - 20)/2,  200, LabelSize.width+20, LabelSize.height+10);
    [UIView animateWithDuration:2.5 animations:^{
        showview.alpha = 0;
    } completion:^(BOOL finished) {
        [showview removeFromSuperview];
    }];
}

#define ScreenWidth [[UIScreen mainScreen] bounds].size.width//获取屏幕宽度

时间: 2024-08-29 17:58:01

iOS 简单提示view的相关文章

IOS简单获取View截图图像(Quartz2D)

1. 先指定图像的大小 UIGraphicsBeginImageContext(view.frame.size); 2. 在指定的区域绘制图像 [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; 3. 获取图像上下文 UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 4. 关闭图像上下文 UIGraphicsEndImageContext();

iOS简单易用的标签列表界面

iOS简单易用的标签列表界面 Demo效果: Demo演示: 1.使用cocoapods引入YZTagListView,或者直接拖入YZTagListView文件夹到项目中 2.导入YZTagListView.h头文件 1 #import "YZTagList.h" 3.创建YZTagListView控件 1 2 3   YZTagList *tagList = [[YZTagList alloc] init];   tagList.backgroundColor = [UIColor

IOS简单的登陆界面

主要需要注意的几个问题: 1.导入图片方式最好用文件导入 代码: 在ViewController.m文件中 2.UILable常用属性 @property(nonatomic,copy)   NSString           *text; //设置文本内容 @property(nonatomic,retain) UIFont             *font; //设置字体 @property(nonatomic,retain) UIColor            *textColor;

ios系统提示音的使用(不是铃声)

AudioServices Jump to: navigation, search AudioServices is a group of C functions in AudioToolbox for playing short (≤30 seconds) sounds. Predefined sounds There are some predefined system sounds, for the system sound ID in the range 1000 to 2000 (de

ios 获取当前view的controller

 //获取view的controller  - (UIViewController *)viewController {     for (UIView* next = [self superview]; next; next = next.superview) {         UIResponder *nextResponder = [next nextResponder];          if ([nextResponder isKindOfClass:[UIViewControll

关于iOS中提示框的使用

关于iOS中提示框的使用在iOS8的SDK里,已经对提示框进行了更改,现在属于 UIAlertController,其接口如下声明NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController,不再是一个UIView. 具体的使用如下,希望对某些朋友有帮助.#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0 //判断你当前的iOS SDK所支持的最大iOS系

iOS 简单实用的一些宏定义

#define WDWBaseURL @"http://192.168.1.1/"  //字符串 #define TOWERTabBarItemTitleOffset UIOffsetMake (0, -3) //点 #define WDWFontColor3d3d3d  [UIColor colorWithRed:61/255.0f  green:61/255.0f  blue:61/255.0f alpha:1]//颜色 #define WDWRedColo [UIColor co

用ios代码做view

import“ViewController.h" @interface ViewController() @end @implementation ViewController -(void)viewDidload { [super viewDidload]; UIView *redview=[[UIView alloc]init]; redview.frame=CGRectMake(0,0,300,100); redview.backgroundcolor=[UIColor redColor]

iOS之Container View获取ViewController

最近使用Container View来在主View Controller建立自己的子Controller,可是遇到问题,不知道如何用代码获取Controller View附带的View Controller. 本想获取了其附带的View Controller,在里面设置代理,然后再主View Controller中实现代理方法,找了很多资料,解决方案如下. 建立一个.h与.m文件,使其关联Container view附带的View Controller,在里面设置代理. 点击Segue,设置Id