Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
@@ -0,0 +1,23 @@
//
// UMComBarButtonItem.h
// UMCommunity
//
// Created by luyiyuan on 14/10/9.
// Copyright (c) 2014年 Umeng. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "UMComButton.h"
@interface UMComBarButtonItem : UIBarButtonItem
@property (nonatomic, assign) CGRect itemFrame;
@property (nonatomic, strong) UMComButton *customButtonView;
- (id)initWithNormalImageNameWithBackItem:(NSString *)imageName target:(id)target action:(SEL)action;
- (id)initWithNormalImageName:(NSString *)imageName target:(id)target action:(SEL)action;
- (id)initWithNormalImageWithBackItem:(UIImage*)image target:(id)target action:(SEL)action;
- (id)initWithNormalImage:(UIImage*)image target:(id)target action:(SEL)action;
- (id)initWithTitle:(NSString *)title target:(id)target action:(SEL)action;
- (id)initWithCustomView:(UIView*)customView;
@end
@@ -0,0 +1,127 @@
//
// UMComBarButtonItem.m
// UMCommunity
//
// Created by luyiyuan on 14/10/9.
// Copyright (c) 2014年 Umeng. All rights reserved.
//
#import "UMComBarButtonItem.h"
#import "UMComButton.h"
#import "UMComResouceDefines.h"
#import <UMComFoundation/UMComKit+Color.h>
@implementation UMComBarButtonItem
- (id)initWithNormalImageNameWithBackItem:(NSString *)imageName target:(id)target action:(SEL)action
{
if(![imageName length]){
return nil;
}
self.customButtonView = [[UMComButton alloc] initWithNormalImageName:imageName target:target action:action];
//创建父控件---begin
UIButton* containerBTN= [UIButton buttonWithType:UIButtonTypeCustom];
containerBTN.frame = self.customButtonView.bounds;
[containerBTN addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
[containerBTN addSubview:self.customButtonView];
//创建父控件---end
self = [super initWithCustomView:containerBTN];
if(self){
}
return self;
}
- (id)initWithNormalImageName:(NSString *)imageName target:(id)target action:(SEL)action
{
if(![imageName length]){
return nil;
}
self.customButtonView = [[UMComButton alloc] initWithNormalImageName:imageName target:target action:action];
self = [super initWithCustomView:self.customButtonView];
if(self){
}
return self;
}
- (id)initWithNormalImageWithBackItem:(UIImage*)image target:(id)target action:(SEL)action
{
if(!image){
return nil;
}
self.customButtonView = [[UMComButton alloc] initWithNormalImage:image target:target action:action];
//self.customButtonView = [[UMComButton alloc] initWithNormalImageName:imageName target:target action:action];
//创建父控件---begin
UIButton* containerBTN= [UIButton buttonWithType:UIButtonTypeCustom];
containerBTN.frame = self.customButtonView.bounds;
[containerBTN addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
[containerBTN addSubview:self.customButtonView];
//创建父控件---end
self = [super initWithCustomView:containerBTN];
if(self){
}
return self;
}
- (id)initWithNormalImage:(UIImage *)image target:(id)target action:(SEL)action
{
if(!image){
return nil;
}
self.customButtonView = [[UMComButton alloc] initWithNormalImage:image target:target action:action];
self = [super initWithCustomView:self.customButtonView];
if(self){
}
return self;
}
- (id)initWithTitle:(NSString *)title target:(id)target action:(SEL)action
{
if(![title length]){
return nil;
}
self.customButtonView = [UMComButton buttonWithType:UIButtonTypeCustom];
[self.customButtonView setFrame:CGRectMake(0, 0, 65, 35)];
[self.customButtonView setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
[self.customButtonView setTitle:title forState:UIControlStateNormal];
[self.customButtonView setTitleColor:UMComColorWithHexString(FontColorBlue) forState:UIControlStateNormal];
[self.customButtonView addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
self = [super initWithCustomView:self.customButtonView];
return self;
}
- (id)initWithCustomView:(UIView*)customView
{
if (!customView) {
return nil;
}
self = [super initWithCustomView:customView];
return self;
}
- (void)setItemFrame:(CGRect)itemFrame
{
_itemFrame = itemFrame;
self.customButtonView.frame = itemFrame;
}
@end
@@ -0,0 +1,18 @@
//
// UMComButton.h
// UMCommunity
//
// Created by luyiyuan on 14/10/9.
// Copyright (c) 2014年 Umeng. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UMComButton : UIButton
- (id)initWithNormalImageName:(NSString *)imageName target:(id)target action:(SEL)action;
- (id)initWithNormalImage:(UIImage *)image target:(id)target action:(SEL)action;
- (id)initWithNormalImage:(UIImage*)image;
- (void)setOrigin:(CGPoint)point;
@end
@@ -0,0 +1,88 @@
//
// UMComButton.m
// UMCommunity
//
// Created by luyiyuan on 14/10/9.
// Copyright (c) 2014年 Umeng. All rights reserved.
//
#import "UMComButton.h"
#import "UMComResouceDefines.h"
@implementation UMComButton
- (id)initWithNormalImageName:(NSString *)imageName target:(id)target action:(SEL)action
{
if(![imageName length]){
return nil;
}
UIImage *image = UMComImageWithImageName(imageName);
self = [self initWithNormalImage:image];
if(self){
UIImage *selectedImage = nil;
if([imageName hasSuffix:@"+x"]){
NSString *resultName = [imageName substringToIndex:[imageName length] - 2];
selectedImage = UMComImageWithImageName(resultName);
}else if([imageName hasSuffix:@"x"]){
NSString *str = [NSString stringWithFormat:@"%@+x",[imageName substringToIndex:[imageName length] - 1]];
selectedImage = UMComImageWithImageName(str);
}
if(selectedImage){
[self setBackgroundImage:selectedImage forState:UIControlStateHighlighted];
}
[self addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
- (id)initWithNormalImage:(UIImage *)image target:(id)target action:(SEL)action
{
if(!image){
return nil;
}
self = [self initWithNormalImage:image];
if(self){
[self addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
- (id)initWithNormalImage:(UIImage*)image
{
if(!image){
return nil;
}
self = [super initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
if(self){
[self setBackgroundImage:image forState:UIControlStateNormal];
}
return self;
}
- (void)setOrigin:(CGPoint)point
{
[self setFrame:CGRectMake(point.x, point.y, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end