自定义提示框,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. docker --help 详解

    [root@c1 _src]# dockerd --help Usage: dockerd [OPTIONS] A self-sufficient runtime for containers. Op ...

  2. CS231n 2016 通关 第三章-SVM 作业分析

    作业内容,完成作业便可熟悉如下内容: cell 1  设置绘图默认参数 # Run some setup code for this notebook. import random import nu ...

  3. SQL 电子书

    http://vdisk.weibo.com/search/?type=&sortby=default&keyword=SQL+Server&filetype=&pag ...

  4. 【eclipse插件开发实战】Eclipse插件开发2——SWT

    Eclipse插件开发实战2--SWT 一.SWT简介 SWT(StandardWidget Toolkit) 标准小窗口工具箱,一开源的GUI编程框架,与AWT/Swing有相似的用处,eclips ...

  5. .after()和.before()的关系

    .after() 是在相邻元素后面插入元素 .next() 获得匹配元素集合中每个元素紧邻的同胞元素 用法介绍: $(selector).after(content) content 必需.规定要插入 ...

  6. Cookie和Session(3)

    关于Cookie和Session Cookie和Session都为了用来保存状态信息,都是保存客户端状态的机制,它们都是为了解决HTTP无状态的问题而所做的努力. 1)cookie 是一种发送到客户浏 ...

  7. 6 手写Java LinkedHashMap 核心源码

    概述 LinkedHashMap是Java中常用的数据结构之一,安卓中的LruCache缓存,底层使用的就是LinkedHashMap,LRU(Least Recently Used)算法,即最近最少 ...

  8. T^TOJ - 1251 - 。◕‿◕。TMD - 欧拉函数 - 质因数分解

    http://www.fjutacm.com/Problem.jsp?pid=1251 想了很久,一开始居然还直接枚举因子d,计算重复了. 首先你要找与n的最大公因子大于m的x的个数. \[\sum\ ...

  9. UTF-8和Unicode互转

    1.Unicode转UTF-8 void CodeCovertTool::UNICODE_to_UTF8(const CString& unicodeString, std::string&a ...

  10. oracle的日期数据类型

    https://blog.csdn.net/qq_33573235/article/details/78154928(转)