自定义BadgeButton提醒数字
来源:互联网 发布:win10网络授权 编辑:程序博客网 时间:2024/05/16 07:46
//
// ZZBadgeButton.h
// ZZ_APP主流框架
//
// Created by ZZ_Macpro on 15/9/27.
// Copyright (c) 2015年 ZZ_Macpro. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ZZBadgeButton :UIButton
@property (nonatomic,copy)NSString *value;
@end
//
// ZZBadgeButton.m
// ZZ_APP主流框架
//
// Created by ZZ_Macpro on 15/9/27.
// Copyright (c) 2015年 ZZ_Macpro. All rights reserved.
//
#import "ZZBadgeButton.h"
@implementation ZZBadgeButton
/**
* 首先设置尺寸
*/
- (id)initWithFrame:(CGRect)frame
{
self = [superinitWithFrame:frame];
if (self) {
self.hidden =YES;
self.userInteractionEnabled =NO;
self.titleLabel.font = [UIFontsystemFontOfSize:12];
[selfsetBackgroundImage:[UIImageresizedImageWithName:@"main_badge"]forState:UIControlStateNormal];
}
return self;
}
/**
* 高亮和普通都保持一致
*/
- (void)setHighlighted:(BOOL)highlighted{ }
/**
* 重写setter方法注意细节
*/
- (void)setValue:(NSString *)value
{
#pragma warning------- NSString 赋值要用copy
_value = [valuecopy];
// 1.设置可见性
if (value.length) {
self.hidden =NO;
// 2.设置尺寸
CGRect frame =self.frame;
frame.size.height =self.currentBackgroundImage.size.height;
if (value.length >1) {
CGSize valueSize = [valuesizeWithFont:self.titleLabel.font];
frame.size.width = valueSize.width +10;
}else {
frame.size.width =self.currentBackgroundImage.size.width;
}
[supersetFrame:frame];
// 3.内容
[selfsetTitle:valueforState:UIControlStateNormal];
}else {
self.hidden =YES;
}
}
- (void)setFrame:(CGRect)frame
{
frame.size =self.frame.size;
[supersetFrame:frame];
}
- (void)setBounds:(CGRect)bounds
{
bounds.size =self.bounds.size;
[supersetBounds:bounds];
}
@end
- 自定义BadgeButton提醒数字
- BadgeView自定义数字提醒控件
- 【新浪微博项目】06--自定义BadgeButton
- android-数字提醒
- BadgeView数字提醒
- BadgeView(数字提醒)
- VS MONO Android开发控件悬浮显示提醒 自定义背景颜色、字体、数字颜色、摆放位置
- jQuery validationEngine自定义提醒
- android badgeView(右上角数字提醒)
- 【Android】AlarmManager 实现提醒一次,每天提醒,周自定义提醒,月自定义提醒
- Android 图标右上角添加数字提醒
- GitHub控件之BadgeView(数字提醒)
- GitHub控件之BadgeView(数字提醒)
- 使用Android ViewBadger——数字提醒
- GitHub控件之BadgeView(数字提醒)
- GitHub控件之BadgeView(数字提醒)
- GitHub控件之BadgeView(数字提醒)
- 关于设置applicationIconBadgeNumber提醒数字的问题
- 最大子数组问题
- CString转char *
- 编写字符驱动程序 - 读取cmos中的时间
- WordPress 函数:add_action()(添加动作)
- CDOJ 1222--Sudoku【DFS && 数独】
- 自定义BadgeButton提醒数字
- 关于去掉Li标签前面的小圆点和距离/显示下划线
- 黑马程序员——网络概念及Socket编程示例
- 安卓 线程 和 线程池
- LeetCode -- Length of last word
- Linux-grep学习笔记
- LeetCode -- Majority Element II
- uva 1599
- poj 2533 Longest Ordered Subsequence (最长上升子序列)