ios 自定义消息提示框

自定义提示框,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 自定义消息提示框的更多相关文章
- iOS:提示框(警告框)控件UIActionSheet的详解
提示框(警告框)控件2:UIActionSheet 功能:当点击按钮或标签等时,弹出一个提示框,显示必要的提示,然后通过添加的按钮完成需要的功能.它与导航栏类似,它继承自UIView. 风格类型: ...
- [ios][swift]提示框,并自动消失
参考: 提示框:http://blog.csdn.net/gishero/article/details/43941361 提示框自动消失:http://www.cnblogs.com/yemingl ...
- Unity 之 自定义消息提示框
简单版: http://blog.csdn.net/caoshuangxiaodouya/article/details/46550655 复杂版: http://www.tuicool.com/ar ...
- mui IOS权限提示框修改
"plistcmds": [ "Set :NSContactsUsageDescription 说明读取用户通讯录的原因", "Set :NSMicr ...
- 自定义iOS 中推送消息 提示框
看到标题你可能会觉得奇怪 推送消息提示框不是系统自己弹出来的吗? 为什么还要自己自定义呢? 因为项目需求是这样的:最近需要做 远程推送通知 和一个客服系统 包括店铺客服和官方客服两个模块 如果有新的消 ...
- iOS开发——UI基础-提示框
提示框的种类有很多,废话不多说,直接上代码 一.文本提示框 运行结果如下: 代码实现如下: @interface ViewController () // 添加方法 - (IBAction)add; ...
- 【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果
原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单.方便,并且可以对显 ...
- iOS bug 之 H5 页面没有弹出提示框
描述:在安卓上有提示框,但是在iOS上没有提示框. step 1: 失误,是我没有在正确的位置设置网址. step 2: 修改之后,测试页能弹出提示框,但是正式的页面没有提示框. step 3: 我输 ...
- iOS - UIAlertController三种显示提示框代码
UIAlertView在IOS 8以上版本已经过时了,官方推荐我们使用UIAlertController代替UIAlertView.UIActionSheet 1、UIAlertController显 ...
随机推荐
- JavaScript-Tool:jquery.qrcode.js
ylbtech-JavaScript-Tool:jquery.qrcode.js 1.返回顶部 1. 插件描述:jquery.qrcode.js 是一个能够在客户端生成矩阵二维码QRCode 的jqu ...
- read,write,accept,connect 超时封装
//read操作加上超时时间. 1 int read_timeout(int fd, void *buf, uint32_t count, int time) { ) { fd_set rSet; F ...
- springmvc源码分析系列-请求处理流程
接上一篇-springmvc源码分析开头片 上一节主要说了一下springmvc与struts2的作为MVC中的C(controller)控制层的一些区别及两者在作为控制层方面的一些优缺点.今天就结合 ...
- URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)
URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs) 有时候在IDEA中配置spring文件 ...
- python序列化之pickle,json,shelve
模块 支持方法 说明 json dumps/dump loads/load 只能处理基本数据类型: 用于多种语言间的数据传输: pickle dumps/dump loads/load 支持pytho ...
- 【废弃中】JavaScript 式与运算符
创建: 2017/09/25 更新: 2019/01/14 修改标题 [JavaScript 式与运算符] -> [JavaScript 式与主要Object的方法] 更新: 2019/02/ ...
- MFC中CArray类原理及其应用
1.CArray类应用 函数简介CArray::GetSize int GetSize( ) const;取得当前数组元素个数. CArray::GetUpperBound int GetUpperB ...
- HDU5920【模拟】
模拟题这种东西啊~就是自己读题,自己打,没有别的方法...贴份6000+b的code跑: #include <bits/stdc++.h> using namespace std; //t ...
- 浅谈volatile关键字
volatile是一种轻量级的同步机制.它可以保证内存可见性以及防止指令重排序,但是不保证原子性 volatile和JMM机制是不可分割的,在谈volatile的时候有必要先了解以下JMM JMM(J ...
- Mysql 到 Hbase 数据如何实时同步,强大的 Streamsets 告诉你
很多情况大数据集群需要获取业务数据,用于分析.通常有两种方式: 业务直接或间接写入的方式 业务的关系型数据库同步到大数据集群的方式 第一种可以是在业务中编写代码,将觉得需要发送的数据发送到消息队列,最 ...