#import "GPDockItem.h"
@implementation
GPDockItem
-(instancetype)initWithFrame:(CGRect)frame{
self
=[
super
initWithFrame:frame];
return
self
;
}
-(
void
)setTitle:(
NSString
*)title{
[
self
setTitle:title forState:UIControlStateNormal];
self
.titleLabel.textAlignment=
NSTextAlignmentCenter
;
self
.titleLabel.font = [UIFont systemFontOfSize:15];
[
self
setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[
self
setTitleColor:[UIColor orangeColor] forState:UIControlStateDisabled];
self
.imageView.contentMode = UIViewContentModeCenter;
}
-(
void
)imageSetting:(
NSString
*)backgroundImage selectedImage:(
NSString
*)selectedImage{
self
.backgroundImage=backgroundImage;
self
.selectedImage=selectedImage;
}
-(
void
)setBackgroundImage:(
NSString
*)backgroundImage{
_backgroundImage=backgroundImage;
[
self
setImage:[UIImage imageNamed:backgroundImage] forState:UIControlStateNormal];
}
-(
void
)setSelectedImage:(
NSString
*)selectedImage{
_selectedImage=selectedImage;
[
self
setImage:[UIImage imageNamed:selectedImage] forState:UIControlStateDisabled];
}
-(CGRect)imageRectForContentRect:(CGRect)contentRect{
CGFloat width=contentRect.size.width;
CGFloat height= contentRect.size.height * 0.7;
return
CGRectMake(0, 10, width, height);
}
-(CGRect)titleRectForContentRect:(CGRect)contentRect{
CGFloat width=contentRect.size.width;
CGFloat height= contentRect.size.height * 0.3;
CGFloat position=contentRect.size.height*0.7;
return
CGRectMake(0, position, width, height);
}
-(
void
)setFrame:(CGRect)frame{
frame.size=CGSizeMake(GPDockItemWidth, GPDockItemHeight);
[
super
setFrame:frame];
}
@end