自定义提示框,3秒钟后自动消失。如上图显示效果。

提示框加载代码:

- (void)viewDidLoad {
[super viewDidLoad]; //将view背景颜色变更为黄色
self.view.backgroundColor = [UIColor yellowColor]; //在self.view上加载提示框
[[BIDNoteView sharedInstance] showNoteView:@"显示提示信息" subView:self.view];
}

BIDNoteView.h 代码:

//
// BIDNoteView.h
// label上画横线
//
// Created by eJiupi on 14-7-23.
// Copyright (c) 2014年 xujinzhong. All rights reserved.
// #import <Foundation/Foundation.h> @interface BIDNoteView : NSObject + (BIDNoteView*)sharedInstance; - (void)showNoteView:(NSString*)noteText subView:(UIView*)subView; -(void)setFont:(UIFont*)font; @end

BIDNoteView.m 实现代码:

//
// BIDNoteView.m
// label上画横线
//
// Created by eJiupi on 14-7-23.
// Copyright (c) 2014年 xujinzhong. All rights reserved.
// #import "BIDNoteView.h" @interface BIDNoteView () //@property (strong, nonatomic) UIView *subView; @property (strong, nonatomic) UIView *noteView;
@property (strong, nonatomic) UILabel *noteLable; @property (strong, nonatomic) NSTimer *timer; @end @implementation BIDNoteView + (BIDNoteView*)sharedInstance
{
static BIDNoteView* instance = nil;
if (instance == nil)
{
instance = [[BIDNoteView alloc] init];
}
return instance;
} - (id)init
{
self = [super init];
if (self)
{
NSInteger w = ;
NSInteger h = ;
NSInteger x = ([UIScreen mainScreen].bounds.size.width-w)/;
NSInteger y = [UIScreen mainScreen].bounds.size.height--h; self.noteView = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
self.noteView.layer.cornerRadius = 5.0;
self.noteView.backgroundColor = [UIColor colorWithRed: green: blue: alpha:0.6]; self.noteLable = [[UILabel alloc] initWithFrame:CGRectMake(, , w, h)];
self.noteLable.text = @"亲,没有更多商品信息了哦";
self.noteLable.numberOfLines=;
self.noteLable.textColor = [UIColor whiteColor];
self.noteLable.textAlignment = NSTextAlignmentCenter;
self.noteLable.backgroundColor = [UIColor clearColor];
[self.noteView addSubview:self.noteLable];
}
return self;
} -(void)setFont:(UIFont*)font
{
self.noteLable.font=font;
} - (void)showNoteView:(NSString*)noteText subView:(UIView*)subView
{
if (self.timer != nil && [self.timer isValid]) {
[self.timer invalidate];
self.timer = nil;
} if (noteText != nil && [noteText length] > )
self.noteLable.text = noteText; [subView addSubview:self.noteView];
[subView layoutIfNeeded];
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO];
} - (void)timerFired:(NSTimer*)timer
{
[self.timer invalidate];
//[self setFont:[BIDDeviceFont font_15]];
[self setFont:[UIFont fontWithName:@"Helvetica" size:]];
self.timer = nil;
[self.noteView removeFromSuperview];
} @end

ios 自定义消息提示框的更多相关文章

  1. iOS:提示框(警告框)控件UIActionSheet的详解

    提示框(警告框)控件2:UIActionSheet 功能:当点击按钮或标签等时,弹出一个提示框,显示必要的提示,然后通过添加的按钮完成需要的功能.它与导航栏类似,它继承自UIView.   风格类型: ...

  2. [ios][swift]提示框,并自动消失

    参考: 提示框:http://blog.csdn.net/gishero/article/details/43941361 提示框自动消失:http://www.cnblogs.com/yemingl ...

  3. Unity 之 自定义消息提示框

    简单版: http://blog.csdn.net/caoshuangxiaodouya/article/details/46550655 复杂版: http://www.tuicool.com/ar ...

  4. mui IOS权限提示框修改

    "plistcmds": [ "Set :NSContactsUsageDescription 说明读取用户通讯录的原因", "Set :NSMicr ...

  5. 自定义iOS 中推送消息 提示框

    看到标题你可能会觉得奇怪 推送消息提示框不是系统自己弹出来的吗? 为什么还要自己自定义呢? 因为项目需求是这样的:最近需要做 远程推送通知 和一个客服系统 包括店铺客服和官方客服两个模块 如果有新的消 ...

  6. iOS开发——UI基础-提示框

    提示框的种类有很多,废话不多说,直接上代码 一.文本提示框 运行结果如下: 代码实现如下: @interface ViewController () // 添加方法 - (IBAction)add; ...

  7. 【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果

    原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单.方便,并且可以对显 ...

  8. iOS bug 之 H5 页面没有弹出提示框

    描述:在安卓上有提示框,但是在iOS上没有提示框. step 1: 失误,是我没有在正确的位置设置网址. step 2: 修改之后,测试页能弹出提示框,但是正式的页面没有提示框. step 3: 我输 ...

  9. iOS - UIAlertController三种显示提示框代码

    UIAlertView在IOS 8以上版本已经过时了,官方推荐我们使用UIAlertController代替UIAlertView.UIActionSheet 1、UIAlertController显 ...

随机推荐

  1. 用C++发邮件

    近段时间,实验室电脑的IP频繁地改变,搞得想用远程偷下懒都不行.这时想到的解决方法有:静态IP,动态域名,自己解决.静态IP虽然可以自己指定,但一关机后,与对方冲突就完了,作罢.免费的动态域名又要手机 ...

  2. 使用Node.js实现简单的网络爬取

    由于最近要实现一个爬取H5游戏的代理服务器,隧看到这么一篇不错的文章(http://blog.miguelgrinberg.com/post/easy-web-scraping-with-nodejs ...

  3. mysql函数之七:replace() MySQL批量替换指定字段字符串

    mysql replace实例说明: UPDATE tb1 SET f1=REPLACE(f1, 'abc', 'def'); REPLACE(str,from_str,to_str) 在字符串 st ...

  4. app自动化测试工具robotium

    robotium基于instramentation框架,可对app白盒黑盒测试,缺点是测试进程和被测进程需要在一个进程中,不能跨应用 白盒测试时,需要app源代码,在eclipse里新建android ...

  5. JAVA基础--JAVA API集合框架16

    一.Map集合 1. map集合介绍 Collection集合的特点: 集合中存储的所有元素都是单一元素,元素和元素之间没有必然的关系.因此我们把Collection集合也称为单列集合. Map集合: ...

  6. 洛谷 - P5429 - Fence Planning - 并查集

    https://www.luogu.org/problemnew/show/P5429 很明显是要维护整个连通块的共同性质,并查集一搞就完事了. #include<bits/stdc++.h&g ...

  7. DOM中元素节点、属性节点、文本节点的理解13.3

    节点信息 每个节点都拥有包含着关于节点某些信息的属性.这些属性是:nodeName(节点名称) nodeValue(节点值) nodeType(节点类型) nodeType nodeType 属性可返 ...

  8. P3803 【模板】多项式乘法(NTT)

    传送门 NTT好像是比FFT快了不少 然而感觉不是很看得懂……主要是点值转化为系数表示那里…… upd:大概已经搞明白是个什么玩意儿了……吧…… //minamoto #include<bits ...

  9. perl 处理特殊字符

    如果大家想使用perl 来处理一些特殊字符,例如"del"这种字符,就需要使用到chr() 函数了 例如大家如果向一个文本中写入以下内容 aaaa0x1270x1bccccc 这时 ...

  10. java 阻塞队列(转)

    转自 http://ifeve.com/java-blocking-queue/ 1. 什么是阻塞队列? 阻塞队列(BlockingQueue)是一个支持两个附加操作的队列.这两个附加的操作是:在队列 ...