Commit 7168a5d8 authored by licong's avatar licong

修改emptyView中的button

parent 3f0d1014
...@@ -20,6 +20,23 @@ ...@@ -20,6 +20,23 @@
[super viewDidLoad]; [super viewDidLoad];
self.pageName = @"yw"; self.pageName = @"yw";
self.title = @"你好"; self.title = @"你好";
OCEmptyView * emptyView = [[OCEmptyView alloc] initWithFrame:CGRectZero];
// emptyView.tipText = @"哎呀!出错了!";
emptyView.tipButton.hidden = NO;
emptyView.type = OCEmptyViewTypeException;
// emptyView.delegate = self;
emptyView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
[self.view addSubview:emptyView];
//
// OCRedGradientButton *button = [OCRedGradientButton buttonWithType:UIButtonTypeCustom];
// button.frame = CGRectMake(60, 100, 100, 50);
// [button setTitle:@"dadasda" forState:UIControlStateNormal];
// [self.view addSubview:button];
} }
- (void)didReceiveMemoryWarning - (void)didReceiveMemoryWarning
......
{ {
"images" : [ "images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "29x29", "size" : "29x29",
...@@ -30,6 +40,16 @@ ...@@ -30,6 +40,16 @@
"size" : "60x60", "size" : "60x60",
"scale" : "3x" "scale" : "3x"
}, },
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{ {
"idiom" : "ipad", "idiom" : "ipad",
"size" : "29x29", "size" : "29x29",
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "network_failed@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "network_failed@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ PODS: ...@@ -15,7 +15,7 @@ PODS:
- AFNetworking/UIKit (3.1.0): - AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession - AFNetworking/NSURLSession
- Base64nl (1.2) - Base64nl (1.2)
- GMBase (0.0.18): - GMBase (0.0.19):
- GMNetService - GMNetService
- GMPhobos - GMPhobos
- GMRefresh - GMRefresh
...@@ -86,7 +86,7 @@ EXTERNAL SOURCES: ...@@ -86,7 +86,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
Base64nl: a497bdcd1c01ea793d36b399016195a8713c0e95 Base64nl: a497bdcd1c01ea793d36b399016195a8713c0e95
GMBase: b437e6f725f488944de4a9a0f3e204a3749ab2fd GMBase: ba0fcf201c116b8b208565bc4ee89bb9ce6343f5
GMCache: 73855b613b9d7e34f4f37ad425e8b8153b760c04 GMCache: 73855b613b9d7e34f4f37ad425e8b8153b760c04
GMFoundation: 395f1083c40aa38e9fb031726991dbc20247e2f9 GMFoundation: 395f1083c40aa38e9fb031726991dbc20247e2f9
GMKit: 2ebe81183532bd05c09ed42cf27a8c61975d5afa GMKit: 2ebe81183532bd05c09ed42cf27a8c61975d5afa
......
{ {
"name": "GMBase", "name": "GMBase",
"version": "0.0.18", "version": "0.0.19",
"summary": "更美iOS APP 的 Objective-C 基础Pod库", "summary": "更美iOS APP 的 Objective-C 基础Pod库",
"homepage": "http://git.gengmei.cc/gengmeiios/GMBase", "homepage": "http://git.gengmei.cc/gengmeiios/GMBase",
"license": "仅限北京更美互动信息科技有限公司内部使用", "license": "仅限北京更美互动信息科技有限公司内部使用",
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
"source": { "source": {
"git": "git@git.gengmei.cc:gengmeiios/GMBase.git", "git": "git@git.gengmei.cc:gengmeiios/GMBase.git",
"tag": "0.0.18" "tag": "0.0.19"
}, },
"platforms": { "platforms": {
"ios": "8.0" "ios": "8.0"
......
...@@ -15,7 +15,7 @@ PODS: ...@@ -15,7 +15,7 @@ PODS:
- AFNetworking/UIKit (3.1.0): - AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession - AFNetworking/NSURLSession
- Base64nl (1.2) - Base64nl (1.2)
- GMBase (0.0.18): - GMBase (0.0.19):
- GMNetService - GMNetService
- GMPhobos - GMPhobos
- GMRefresh - GMRefresh
...@@ -86,7 +86,7 @@ EXTERNAL SOURCES: ...@@ -86,7 +86,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
Base64nl: a497bdcd1c01ea793d36b399016195a8713c0e95 Base64nl: a497bdcd1c01ea793d36b399016195a8713c0e95
GMBase: b437e6f725f488944de4a9a0f3e204a3749ab2fd GMBase: ba0fcf201c116b8b208565bc4ee89bb9ce6343f5
GMCache: 73855b613b9d7e34f4f37ad425e8b8153b760c04 GMCache: 73855b613b9d7e34f4f37ad425e8b8153b760c04
GMFoundation: 395f1083c40aa38e9fb031726991dbc20247e2f9 GMFoundation: 395f1083c40aa38e9fb031726991dbc20247e2f9
GMKit: 2ebe81183532bd05c09ed42cf27a8c61975d5afa GMKit: 2ebe81183532bd05c09ed42cf27a8c61975d5afa
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.0.18</string> <string>0.0.19</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
#import "Phobos.h" #import "Phobos.h"
#import "PhobosConfig.h" #import "PhobosConfig.h"
#import "PhobosPVProtocol.h"
#import "PhobosUtil.h" #import "PhobosUtil.h"
#import "UIResponder+PhobosPV.h"
FOUNDATION_EXPORT double GMPhobosVersionNumber; FOUNDATION_EXPORT double GMPhobosVersionNumber;
FOUNDATION_EXPORT const unsigned char GMPhobosVersionString[]; FOUNDATION_EXPORT const unsigned char GMPhobosVersionString[];
......
...@@ -8,6 +8,11 @@ ...@@ -8,6 +8,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface OCRedGradientButton : UIButton
@end
typedef NS_ENUM(NSUInteger, OCEmptyViewType) { typedef NS_ENUM(NSUInteger, OCEmptyViewType) {
OCEmptyViewTypeEmpty, OCEmptyViewTypeEmpty,
OCEmptyViewTypeException OCEmptyViewTypeException
...@@ -22,12 +27,9 @@ typedef NS_ENUM(NSUInteger, OCEmptyViewType) { ...@@ -22,12 +27,9 @@ typedef NS_ENUM(NSUInteger, OCEmptyViewType) {
@interface OCEmptyView : UIView @interface OCEmptyView : UIView
@property (nonatomic, strong) UIImageView *tipIcon; @property (nonatomic, strong) UIImageView *tipIcon;
@property (nonatomic, strong) UILabel *tipLabel; @property (nonatomic, strong) UILabel *tipLabel;
@property (nonatomic, strong) UIButton *tipButton; @property (nonatomic, strong) OCRedGradientButton *tipButton;
@property (nonatomic, assign) OCEmptyViewType type; @property (nonatomic, assign) OCEmptyViewType type;
@property (nonatomic, weak) id<OCEmptyViewDelegate> delegate; @property (nonatomic, weak) id<OCEmptyViewDelegate> delegate;
@property (nonatomic, copy) NSString *emptyImage; @property (nonatomic, copy) NSString *tipImage;
@property (nonatomic, copy) NSString *emptyText; @property (nonatomic, copy) NSString *tipText;
@property (nonatomic, copy) NSString *exceptionImage;
@property (nonatomic, copy) NSString *exceptionText;
@end @end
...@@ -10,6 +10,61 @@ ...@@ -10,6 +10,61 @@
#import "GMBaseUtil.h" #import "GMBaseUtil.h"
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
@implementation OCRedGradientButton
-(id)init
{
self = [super init];
if (self) {
}
return self;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.clipsToBounds = YES;
}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
self.layer.cornerRadius = MIN(self.frame.size.height, self.frame.size.width)/2;
}
- (void)drawRect:(CGRect)rect{
NSArray *colors = @[[UIColor colorWithRed:1 green:89.0/255 blue:99.0/255 alpha:1],[UIColor colorWithRed:1 green:112.0/255 blue:150.0/255 alpha:1]];
NSMutableArray *ar = [NSMutableArray array];
for(UIColor *c in colors) {
[ar addObject:(id)c.CGColor];
}
UIGraphicsBeginImageContextWithOptions(self.frame.size, YES, 1);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGColorSpaceRef colorSpace = CGColorGetColorSpace([[colors lastObject] CGColor]);
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)ar, NULL);
CGPoint start = CGPointMake(self.frame.size.width, 0.0);
CGPoint end = CGPointMake(0, self.frame.size.height);
CGContextDrawLinearGradient(context, gradient, start, end, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
CGGradientRelease(gradient);
CGContextRestoreGState(context);
CGColorSpaceRelease(colorSpace);
UIGraphicsEndImageContext();
[self setBackgroundImage:image forState:UIControlStateNormal];
[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
@end
@implementation OCEmptyView @implementation OCEmptyView
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
...@@ -27,80 +82,67 @@ ...@@ -27,80 +82,67 @@
} }
- (void)setup{ - (void)setup{
self.backgroundColor = [UIColor colorWithhex:0xf0f0f0]; self.backgroundColor = [UIColor whiteColor];
_tipIcon = [UIImageView new]; _tipIcon = [UIImageView new];
_tipLabel = [UILabel new]; _tipLabel = [UILabel new];
_tipButton = [UIButton buttonWithType:UIButtonTypeCustom]; _tipButton = [OCRedGradientButton buttonWithType:UIButtonTypeCustom];
[self addSubview:_tipIcon]; [self addSubview:_tipIcon];
[self addSubview:_tipLabel]; [self addSubview:_tipLabel];
[self addSubview:_tipButton]; [self addSubview:_tipButton];
_tipLabel.numberOfLines = 2; _tipLabel.numberOfLines = 2;
_tipLabel.textColor = [UIColor colorWithhex:0x999999]; _tipLabel.preferredMaxLayoutWidth = 160;
_tipLabel.font = [UIFont navigationFontWithSize:14]; _tipLabel.textColor = [UIColor colorWithhex:0x666666];
_tipLabel.font = [UIFont navigationFontWithSize:15];
_tipLabel.textAlignment = NSTextAlignmentCenter; _tipLabel.textAlignment = NSTextAlignmentCenter;
_tipButton.layer.borderColor = [UIColor colorWithhex:0xd5d5d5].CGColor;
_tipButton.layer.borderWidth = 1.0/[UIScreen mainScreen].scale;
_tipButton.hidden = YES; _tipButton.hidden = YES;
[_tipButton setTitle:@"重新加载" forState:UIControlStateNormal]; [_tipButton setTitle:@"重新加载" forState:UIControlStateNormal];
_tipButton.titleLabel.font = [UIFont navigationFontWithSize:14]; _tipButton.titleLabel.font = [UIFont navigationFontWithSize:16];
[_tipButton setTitleColor:[UIColor colorWithhex:0x666666] forState:UIControlStateNormal]; [_tipButton setTitleColor:[UIColor colorWithhex:0x666666] forState:UIControlStateNormal];
[_tipButton addTarget:self action:@selector(reloadBtnTap) forControlEvents:UIControlEventTouchUpInside]; [_tipButton addTarget:self action:@selector(reloadBtnTap) forControlEvents:UIControlEventTouchUpInside];
_exceptionImage = @"network_failed_icon";
_exceptionText = @"网络请求失败,请检查您的网络设置";
_emptyImage = @"empty_icon";
_emptyText = @"";
} }
- (void)layoutSubviews { - (void)layoutSubviews {
[super layoutSubviews]; [super layoutSubviews];
switch (self.type) {
case OCEmptyViewTypeEmpty: {
_tipIcon.image = [UIImage imageNamed:_emptyImage];
_tipLabel.text = _emptyText;
_tipButton.hidden = YES;
[_tipIcon mas_remakeConstraints:^(MASConstraintMaker *make) { [_tipIcon mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self); make.centerX.equalTo(self);
make.centerY.equalTo(self).offset(-50); make.centerY.equalTo(self).offset(-75);
make.width.mas_equalTo(140);
make.height.mas_equalTo(93);
}]; }];
[_tipLabel mas_remakeConstraints:^(MASConstraintMaker *make) { [_tipLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tipIcon.mas_bottom).offset(25); make.top.equalTo(_tipIcon.mas_bottom).offset(-35);
make.height.mas_equalTo(50);
make.width.mas_equalTo(280);
make.centerX.mas_equalTo(self); make.centerX.mas_equalTo(self);
}]; }];
switch (self.type) {
case OCEmptyViewTypeEmpty:{
_tipButton.hidden = YES;
_tipIcon.image = [UIImage imageNamed:@"empty"];
_tipLabel.text = @"哦买噶~空空如也";
break; break;
} }
case OCEmptyViewTypeException: { case OCEmptyViewTypeException:{
_tipIcon.image = [UIImage imageNamed:_exceptionImage];
_tipLabel.text = _exceptionText;
_tipButton.hidden = NO; _tipButton.hidden = NO;
[_tipIcon mas_remakeConstraints:^(MASConstraintMaker *make) { _tipIcon.image = [UIImage imageNamed:@"network_failed"];
make.centerX.equalTo(self); _tipLabel.text = @"哎呀!出错了!";
make.centerY.equalTo(self).offset(-50);
make.width.mas_equalTo(100);
make.height.mas_equalTo(81);
}];
[_tipLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(25);
make.top.equalTo(_tipIcon.mas_bottom).offset(15);
make.centerX.equalTo(self);
}];
[_tipButton mas_remakeConstraints:^(MASConstraintMaker *make) { [_tipButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tipLabel.mas_bottom).offset(15); make.top.equalTo(_tipIcon.mas_bottom).offset(15);
make.centerX.equalTo(self); make.centerX.equalTo(self);
make.width.mas_equalTo(90); make.width.mas_equalTo(150);
make.height.mas_equalTo(30); make.height.mas_equalTo(33);
}]; }];
} }
default: default:
break; break;
} }
if (_tipImage.length > 0) {
_tipIcon.image = [UIImage imageNamed:_tipImage];
}
if (_tipText.length > 0) {
_tipLabel.text = _tipText;
}
} }
- (void)reloadBtnTap { - (void)reloadBtnTap {
if ([self.delegate respondsToSelector:@selector(emptyViewDidClickReload)]) { if ([self.delegate respondsToSelector:@selector(emptyViewDidClickReload)]) {
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
_emptyView = [[OCEmptyView alloc] initWithFrame:CGRectZero]; _emptyView = [[OCEmptyView alloc] initWithFrame:CGRectZero];
_emptyView.hidden = YES; _emptyView.hidden = YES;
if([self getEmptyText].length > 0){ if([self getEmptyText].length > 0){
_emptyView.emptyText = [self getEmptyText]; _emptyView.tipText = [self getEmptyText];
} }
_emptyView.delegate = self; _emptyView.delegate = self;
[self.view addSubview:_emptyView]; [self.view addSubview:_emptyView];
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
- (void)showEmptyView:(OCEmptyViewType)type { - (void)showEmptyView:(OCEmptyViewType)type {
_emptyView.type = type; _emptyView.type = type;
_emptyView.hidden = NO; _emptyView.hidden = NO;
[self getEmptyText]; _emptyView.tipText = [self getEmptyText];
[_emptyView setNeedsLayout]; [_emptyView setNeedsLayout];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment