1.首先进入这个平台
https://open.weixin.qq.com
2.创建应用 如果需要填Bundle id
Bundle id: com.optaim.tiantianyouyi
按提示步骤来即可
3.审核通过后
import "IMJIETagView.h"
@implementation IMJIETagView
-(id)initWithFrame<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
selectedBtnList = [[NSMutableArray alloc] init];
self.clickBackgroundColor = [UIColor whiteColor];
self.clickTitleColor = TextColor;
self.clickArray = nil;
self.clickbool = YES;
self.borderSize = 0.5;
self.clickborderSize =0.5;
}
return self;
}
-(void)setTagsFrame<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">IMJIETagFrame *)tagsFrame{
_tagsFrame = tagsFrame;
for (NSInteger i=0; i<tagsFrame.tagsArray.count; i++) {
UIButton *tagsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[tagsBtn setTitle:tagsFrame.tagsArray<i> forState:UIControlStateNormal];
[tagsBtn setTitleColor:TextColor forState:UIControlStateNormal];
tagsBtn.titleLabel.font = TagTitleFont;
tagsBtn.tag = i;
tagsBtn.backgroundColor = [UIColor whiteColor];
[self makeCorner:self.borderSize view:tagsBtn color:UIColorRGBA(221, 221, 221, 1)];
tagsBtn.frame = CGRectFromString(tagsFrame.tagsFrames<i>);
[tagsBtn addTarget:self action<img src="static/image/smiley/default/huffy.gif" smilieid="5" border="0" alt="">selector(TagsBtn<img src="static/image/smiley/default/smile.gif" smilieid="1" border="0" alt=""> forControlEvents:UIControlEventTouchDown];
tagsBtn.enabled = _clickbool;
[self addSubview:tagsBtn];
}
}
pragma mark 选中背景颜色
-(void)setClickBackgroundColor<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">UIColor *)clickBackgroundColor{
if (_clickBackgroundColor != clickBackgroundColor) {
_clickBackgroundColor = clickBackgroundColor;
}
}
pragma makr 选中字体颜色
-(void)setClickTitleColor<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">UIColor *)clickTitleColor{
if (_clickTitleColor != clickTitleColor) {
_clickTitleColor = clickTitleColor;
}
}
pragma makr 能否被选中
-(void)setClickbool<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">BOOL)clickbool{
_clickbool = clickbool;
}
pragma makr 未选中边框大小
-(void)setBorderSize<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">CGFloat)borderSize{
if (_borderSize!=borderSize) {
_borderSize = borderSize;
}
}
pragma makr 选中边框大小
-(void)setClickborderSize<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">CGFloat)clickborderSize{
if (_clickborderSize!= clickborderSize) {
_clickborderSize = clickborderSize;
}
}
pragma makr 默认选择 单选
-(void)setClickString<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">NSString *)clickString{
if (_clickString != clickString) {
_clickString = clickString;
}
if ([_tagsFrame.tagsArray containsObject:_clickString]) {
NSInteger index = [_tagsFrame.tagsArray indexOfObject:_clickString];
[self ClickString:index];
}
}
pragma mark 默认选择 多选
-(void)setClickArray<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">NSArray *)clickArray{
if (_clickArray != clickArray) {
_clickArray = clickArray;
}
for (NSString *string in clickArray) {
if ([_tagsFrame.tagsArray containsObject:string]) {
NSInteger index = [_tagsFrame.tagsArray indexOfObject:string];
NSString *x = [[NSString alloc] initWithFormat<img src="static/image/smiley/default/huffy.gif" smilieid="5" border="0" alt="">"%ld",(long)index];
[self ClickArray:x];
}
}
}
pragma makr 单选
-(void)ClickString<img src="static/image/smiley/default/sad.gif" smilieid="2" border="0" alt="">NSInteger )index{
UIButton *btn;
for (id obj in self.subviews) {
if ([obj isKindOfClass:[UIButton class]]) {
btn = (UIButton *)obj;
if (btn.tag == index){
btn.backgroundColor = [UIColor whiteColor];
[btn setTitleColor:_clickTitleColor forState:UIControlStateNormal];
[self makeCorner:_clickborderSize view:btn color:_clickTitleColor];
[_delegate IMJIETagView<img src="static/image/smiley/default/huffy.gif" smilieid="5" border="0" alt="">[[NSString stringWithFormat<img src="static/image/smiley/default/huffy.gif" smilieid="5" border="0" alt="">"%ld",(long)index]]];
}else{
btn.backgroundColor = [UIColor whiteColor];
[btn setTitleColor:TextColor forState:UIControlStateNormal];
[self makeCorner:_borderSize view:btn color:UIColorRGBA(221, 221, 221, 1)];
}
}
}
}
pragma mark 多选
-(void)ClickArray:(NSString *)index{
UIButton *btn;
for (id obj in self.subviews) {
if ([obj isKindOfClass:[UIButton class]]) {
btn = (UIButton *)obj;
if (btn.tag == [index integerValue]){
if ([selectedBtnList containsObject:index]) {
btn.backgroundColor = [UIColor whiteColor];
[btn setTitleColor:TextColor forState:UIControlStateNormal];
[self makeCorner:_borderSize view:btn color:UIColorRGBA(221, 221, 221, 1)];
[selectedBtnList removeObject:index];
}else{
btn.backgroundColor = [UIColor whiteColor];
[btn setTitleColor:_clickTitleColor forState:UIControlStateNormal];
[self makeCorner:_clickborderSize view:btn color:_clickTitleColor];
[selectedBtnList addObject:index];
}
[_delegate IMJIETagView:selectedBtnList];
}
}
}
}
-(void)makeCorner:(CGFloat)corner view:(UIView *)view color:(UIColor *)color{
CALayer * fileslayer = [view layer];
fileslayer.borderColor = [color CGColor];
fileslayer.borderWidth = corner;
}
-(void)TagsBtn:(UIButton *)sender{
if (self.clickStart == 0) {
//单选
[self ClickString:sender.tag];
}else{
//多选
NSString *x = [[NSString alloc] initWithFormat<img src="static/image/smiley/default/huffy.gif" smilieid="5" border="0" alt="">"%ld",(long)sender.tag];
[self ClickArray:x];
}
}
@end</i></i>