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显 ...
随机推荐
- C++之面向对象初探----对象管理模型(关键是this指针)
前言 c++对象模型可以概括为以下2部分 1.语言中直接支持面向对象程序员设计部分,主要涉及如构造函数.析构函数.虚函数.继承(单继承.多继承.虚继承).多态等待. 2.对于各种支持的底层实现机制 在 ...
- bzoj2718
二分图匹配 首先有个定理:最长反链=最小链覆盖 最小链覆盖可以重复经过点 所以我们不能直接建图 那么我们用floyd判断是否相连 然后建图就行了 #include<bits/stdc++.h&g ...
- FileWriter 写文件
FileWriter fw = new FileWriter("C://Users//pc//Desktop//aaa.txt",true); fw.write("201 ...
- c# 调用 webservices (转载)
.net 调用webservice 总结 最近做一个项目,由于是在别人框架里开发app,导致了很多限制,其中一个就是不能直接引用webservice . 我们都知道,调用webserivice 最简单 ...
- Angular6在自定义指令中使用@HostBingDing() 和@HostListener()
emmm,,,最近在为项目的第二阶段铺路,偶然看到directive,想想看因为项目已经高度集成了第三方组件,所以对于自定义指令方面的经验自己实在知之甚少,后面经过阅读相关资料,总结一篇关于在自定义指 ...
- 序列化框架MJExtension详解 + iOS ORM框架
当开发中你的模型中属性名称和 字典(JSON/XML) 中的key 不能一一对应时, 或者当字典中嵌套了多层字典数组时..., 以及教你如何用 MJExtension 配置类来统一管理你的模型配置, ...
- C++里的强制类型转换符reinterpret_cast、static_cast 、dynamic_cast、const_cast 区别
C 风格(C-style)强制转型如下: (T) exdivssion // cast exdivssion to be of type T 函数风格(Function-style)强制转型使用这样的 ...
- HDU4255【BFS】
题意: 给你一个矩阵,矩阵里是的数是这么安排的,然后给你两个数,让你求这两个数的最短距离,素数不能去: 思路: 预处理一下素数表,矩阵,然后找一下起点和终点的坐标,跑一下BFS就好了: #includ ...
- 浅谈C++中内存泄漏的检测
首先我们需要知道程序有没有内存泄露,然后定位到底是哪行代码出现内存泄露了,这样才能将其修复.最简单的方法当然是借助于专业的检测工具,比较有名如BoundsCheck,功能非常强大,相信做C++开发的人 ...
- 51nod1416(dfs)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1416 题意:中文题诶- 思路:dfs 搜索同一颜色的点.. 只 ...