自定义一个发状态的工具栏toolbar(类似QQ和微博的发状态的工具栏)
来源:互联网 发布:手机淘宝apk下载 编辑:程序博客网 时间:2024/06/05 01:57
//
// ZZComposeToolbar.h
// ZZ_APP主流框架
//
// Created by ZZ_Macpro on 15/10/12.
// Copyright (c) 2015年 ZZ_Macpro. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ZZComposeToolbar;
typedef enum {
ZZComposeToolbarButtonTypeCamera,
ZZComposeToolbarButtonTypePicture,
ZZComposeToolbarButtonTypeMention,
ZZComposeToolbarButtonTypeTrend,
ZZComposeToolbarButtonTypeEmotion
} ZZComposeToolbarButtonType;
@protocol ZZComposeToolbarDelegate <NSObject>
@optional
- (void)composeToolbar:(ZZComposeToolbar *)toolbar didClickedButton:(ZZComposeToolbarButtonType)buttonType;
@end
@interface ZZComposeToolbar :UIView
@property (weak, nonatomic) id<ZZComposeToolbarDelegate> delegate;
@end
//
// ZZComposeToolbar.m
// ZZ_APP主流框架
//
// Created by ZZ_Macpro on 15/10/12.
// Copyright (c) 2015年 ZZ_Macpro. All rights reserved.
//
#import "ZZComposeToolbar.h"
@implementation ZZComposeToolbar
- (id)initWithFrame:(CGRect)frame
{
self = [superinitWithFrame:frame];
if (self) {
// 1.设置背景
self.backgroundColor = [UIColorcolorWithPatternImage:[UIImageimageWithName:@"compose_toolbar_background"]];
// 2.添加按钮
[selfaddButtonWithIcon:@"compose_camerabutton_background"highIcon:@"compose_camerabutton_background_highlighted"tag:ZZComposeToolbarButtonTypeCamera];
[selfaddButtonWithIcon:@"compose_toolbar_picture"highIcon:@"compose_toolbar_picture_highlighted"tag:ZZComposeToolbarButtonTypePicture];
[selfaddButtonWithIcon:@"compose_mentionbutton_background"highIcon:@"compose_mentionbutton_background_highlighted"tag:ZZComposeToolbarButtonTypeMention];
[selfaddButtonWithIcon:@"compose_trendbutton_background"highIcon:@"compose_trendbutton_background_highlighted"tag:ZZComposeToolbarButtonTypeTrend];
[selfaddButtonWithIcon:@"compose_emoticonbutton_background"highIcon:@"compose_emoticonbutton_background_highlighted"tag:ZZComposeToolbarButtonTypeEmotion];
}
return self;
}
- (void)addButtonWithIcon:(NSString *)icon highIcon:(NSString *)highIcon tag:(int)tag
{
UIButton *button = [[UIButtonalloc] init];
button.tag = tag;
[button addTarget:selfaction:@selector(buttonClick:)forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImageimageWithName:icon] forState:UIControlStateNormal];
[button setImage:[UIImageimageWithName:highIcon] forState:UIControlStateHighlighted];
[selfaddSubview:button];
}
/**
* 监听按钮点击
*/
- (void)buttonClick:(UIButton *)button
{
if ([self.delegaterespondsToSelector:@selector(composeToolbar:didClickedButton:)]) {
[self.delegatecomposeToolbar:selfdidClickedButton:button.tag];
}
}
- (void)layoutSubviews
{
[superlayoutSubviews];
CGFloat buttonW =self.frame.size.width /self.subviews.count;
CGFloat buttonH = self.frame.size.height;
for (int i =0; i<self.subviews.count; i++) {
UIButton *button = self.subviews[i];
CGFloat buttonX = buttonW * i;
button.frame =CGRectMake(buttonX, 0, buttonW, buttonH);
}
}
@end
- 自定义一个发状态的工具栏toolbar(类似QQ和微博的发状态的工具栏)
- html中类似qq评论和发状态的布局实现-初学者
- 工具栏ToolBar的使用
- 自定义工具栏 (ToolBar) 控件的外观
- MFC工具栏的创建和实现ToolBar
- 6.17--如何 保持和恢复 工具栏 的位置和状态?
- WTL 工具栏与状态的更新
- 改变工具栏按钮状态的方法
- 校内发状态的神器
- 类似qq发说说的查看全文和收起
- 自定义myeclipse的工具栏
- 创建自定义的工具栏
- 自定义Office 97的菜单和工具栏
- 工具栏ToolBar上的CComboBox响应回车
- 工具栏ToolBar上的CComboBox响应回车
- 工具栏ToolBar上的CComboBox响应回车
- 工具栏ToolBar上的CComboBox响应回车
- extjs中Toolbar工具栏的用法
- 程序设计题: 命题逻辑应用系统
- 在java中实现输入两个正整数m和n,求最大的公约数和最小公倍数
- ssh正向隧道
- JavaScript数组小结
- 乘积最大<DP><C++>
- 自定义一个发状态的工具栏toolbar(类似QQ和微博的发状态的工具栏)
- Python 列表(List)操作方法详解
- Android性能优化 浅析
- 十款常见的开源数据库学习资料大汇总
- 自己开发实现OAuth做webapi认证
- maven-git-commit-id-plugin插件,jar包带上git commit相关信息
- 问题:无法访问 private 成员(在“CObject”类中声明)
- 智能该如何做
- 黑马程序员_IO流的一些总结