Commit 6e4d3363 by lee

Merge branch 'master' of git.oschina.net:kollway-kollway/newcemarose

parents 4031d8f7 24c0de27
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_down@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_down@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
//
// KWMBrandsImage.h
// iCemarose
//
// Created by 陈荣科 on 2016/11/8.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMBaseModel.h"
@interface KWMBrandsImage : KWMBaseModel
@property (nonatomic) NSString *handle;
@property (nonatomic) NSDictionary *image;
@property (nonatomic) NSString *title;
- (NSString *)getImageScr;
@end
//
// KWMBrandsImage.m
// iCemarose
//
// Created by 陈荣科 on 2016/11/8.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMBrandsImage.h"
@implementation KWMBrandsImage
- (NSString *)getImageScr{
return [_image objectForKey:@"scr"];
}
@end
//
// KWMFilter.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/7.
// Copyright © 2017年 kollway. All rights reserved.
//
// 筛选model
//
#import <JSONModel/JSONModel.h>
#import <Foundation/Foundation.h>
@interface KWMFilter : KWMBaseModel
//filter tag group name
@property (nonatomic) NSString *group;
//tags
@property(nonatomic) NSMutableArray<NSString *> *tags;
@end
//
// KWMFilter.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMFilter.h"
@implementation KWMFilter
@end
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// //
#import <JSONModel/JSONModel.h> #import <JSONModel/JSONModel.h>
#import "KWMBaseModel.h"
@interface KWMOrder : KWMBaseModel @interface KWMOrder : KWMBaseModel
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#import "KWMBarandSelectView.h" #import "KWMBarandSelectView.h"
#import "Buy/Buy.h" #import "Buy/Buy.h"
#import "KWMNewGoodsModel.h" #import "KWMNewGoodsModel.h"
#import "KWMFilterView.h" #import "KWMNormalFilterTab.h"
#import "KWMFilterVC.h" #import "KWMNormalFilterView.h"
@interface KWMBrandCaramelVC : KWMBasePageVC<KWMBarandSelectViewDelegate,KWMFilterDelegate,KWMFilterVCDelegate> @interface KWMBrandCaramelVC : KWMBasePageVC<KWMBarandSelectViewDelegate,KWMNormalFilterTabDelegate,KWMFilterDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tbvBrandCaramel; @property (weak, nonatomic) IBOutlet UITableView *tbvBrandCaramel;
@property (weak, nonatomic) IBOutlet UITextView *tvDescription; @property (weak, nonatomic) IBOutlet UITextView *tvDescription;
...@@ -22,20 +22,16 @@ ...@@ -22,20 +22,16 @@
@property (weak, nonatomic) IBOutlet UIImageView *ivBrand; @property (weak, nonatomic) IBOutlet UIImageView *ivBrand;
//@property (weak, nonatomic) IBOutlet UIView *vScreen;//筛选view //@property (weak, nonatomic) IBOutlet UIView *vScreen;//筛选view
@property (weak, nonatomic) IBOutlet UIView *vBlurred;//模糊背景
@property (weak, nonatomic) IBOutlet UIView *vNoneGoods;//没有商品 @property (weak, nonatomic) IBOutlet UIView *vNoneGoods;//没有商品
@property (weak, nonatomic) IBOutlet UIView *vFilter;//筛选空间容器
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *vBackgroudTop; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *vBackgroudTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tvDescriptionTop; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *tvDescriptionTop;
@property (weak, nonatomic) IBOutlet KWMFilterView *filterView; @property (weak, nonatomic) IBOutlet KWMNormalFilterTab *filterTab;
@property (weak, nonatomic) IBOutlet KWMNormalFilterView *filterView;
@property (nonatomic) BOOL isLoading; @property (nonatomic) BOOL isLoading;
@property (nonatomic) BUYCollectionSort collectionSort;
@property (nonatomic) BUYCollection *collection; @property (nonatomic) BUYCollection *collection;
@property (nonatomic) NSString *brand; @property (nonatomic) NSString *brand;
@property (nonatomic) NSString *handle;//搜索品牌字段 @property (nonatomic) NSString *handle;//搜索品牌字段
...@@ -48,8 +44,5 @@ ...@@ -48,8 +44,5 @@
- (IBAction)onClickBotomBtn:(id)sender; - (IBAction)onClickBotomBtn:(id)sender;
- (IBAction)onClickFilter:(id)sender;
- (IBAction)onClickSort:(id)sender;
@end @end
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
#import "UIImageView+WebCache.h" #import "UIImageView+WebCache.h"
#import "KWMImageUtil.h" #import "KWMImageUtil.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "KWMFilterUtil.h"
#import "UIColor+SAMAdditions.h" #import "UIColor+SAMAdditions.h"
#import "MJRefresh.h"
#import "KWMFilterVC.h" #import "KWMFilterVC.h"
#import "KWMImageBlurUtil.h"
#import "KWMShoppingCart.h" #import "KWMShoppingCart.h"
#import <RXCollections/RXCollection.h> #import <RXCollections/RXCollection.h>
...@@ -57,38 +58,12 @@ ...@@ -57,38 +58,12 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
self.collectionSort = BUYCollectionSortCreatedDescending;
self.filterView.delegate = self;
self.automaticallyAdjustsScrollViewInsets = NO;
self.tvDescription.editable = NO;
mark = -1;
self.vNoneGoods.backgroundColor = [UIColor colorWithRed:244.0/255 green:245.0/255 blue:247.0/255 alpha:1];
self.tbvBrandCaramel.separatorStyle = UITableViewCellSeparatorStyleNone;
_tvDescription.hidden = YES;
_btnBottom.hidden = YES;
if (_backColor) {
_ivBrand.backgroundColor = _backColor;
}else{
[self setBackColor];
}
[self initView]; [self initView];
[self getCollection:_handle]; [self getCollection:_handle];
if(self.goodModel){ if(self.goodModel){
[self initCacheData]; [self initCacheData];
} }
[self initFilterVC];
}
-(void)initFilterVC{
if(!filterVC){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"New" bundle:nil];
filterVC = [storyboard instantiateViewControllerWithIdentifier:[KWMFilterVC kwmTag]];
[self addChildViewController:filterVC];
[self.vFilter addSubview:filterVC.view];
filterVC.delegate = self;
}
} }
-(void)initCacheData{ -(void)initCacheData{
...@@ -121,7 +96,6 @@ ...@@ -121,7 +96,6 @@
} }
-(void)loadData{ -(void)loadData{
// [self showLoading];
if(self.collection!=nil && self.collection.identifier!=nil){ if(self.collection!=nil && self.collection.identifier!=nil){
[self getProcduct:self.collection.identifier]; [self getProcduct:self.collection.identifier];
} }
...@@ -129,7 +103,6 @@ ...@@ -129,7 +103,6 @@
-(void)reLoadData{ -(void)reLoadData{
self.currentPage = 0; self.currentPage = 0;
// [self showLoading];
if(self.collection!=nil && self.collection.identifier!=nil){ if(self.collection!=nil && self.collection.identifier!=nil){
[self getProcduct:self.collection.identifier]; [self getProcduct:self.collection.identifier];
}} }}
...@@ -140,20 +113,6 @@ ...@@ -140,20 +113,6 @@
_barandSelectView.count = [[KWMShoppingCart sharedInstance] count].integerValue; _barandSelectView.count = [[KWMShoppingCart sharedInstance] count].integerValue;
_barandSelectView.lbBrand.text = [_brand uppercaseString]; _barandSelectView.lbBrand.text = [_brand uppercaseString];
rightButton =[UIButton buttonWithType:UIButtonTypeRoundedRect];
rightButton.frame = CGRectMake(UI_SCREEN_WIDTH-100, 33, 40, 20);
[rightButton addTarget:self action:@selector(clickRightButton) forControlEvents:UIControlEventTouchUpInside];
[rightButton setTitle:@"排序 +" forState:UIControlStateNormal];
[rightButton setTitleColor:[UIColor sam_colorWithHex:@"4E4E4E"] forState:UIControlStateNormal];
rightButton.titleLabel.font=[UIFont systemFontOfSize:11];
[rightButton.layer setMasksToBounds:YES];
rightButton.layer.cornerRadius = 1; //圆角(圆形)
rightButton.layer.borderColor = [UIColor sam_colorWithHex:@"4E4E4E"].CGColor; //要设置的颜色
rightButton.layer.borderWidth = 1; //要设置的描边宽
[self.barandSelectView addSubview:rightButton];
[self.view addSubview:_barandSelectView]; [self.view addSubview:_barandSelectView];
_barandSelectView.delegate = self; _barandSelectView.delegate = self;
} }
...@@ -164,7 +123,10 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -164,7 +123,10 @@ static NSString *idStr = @"KWMBrandCaramelCell";
isUp = NO; isUp = NO;
backgroundTop = 210; backgroundTop = 210;
tvTop = 255; tvTop = 255;
mark = -1;
self.automaticallyAdjustsScrollViewInsets = NO;
self.hasNextPage = NO;
self.tbvBrandCaramel.delegate = self; self.tbvBrandCaramel.delegate = self;
self.tbvBrandCaramel.showsVerticalScrollIndicator = NO; self.tbvBrandCaramel.showsVerticalScrollIndicator = NO;
[self.tbvBrandCaramel registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr]; [self.tbvBrandCaramel registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr];
...@@ -173,6 +135,15 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -173,6 +135,15 @@ static NSString *idStr = @"KWMBrandCaramelCell";
if(self.goodModel!=nil && self.goodModel.comments!=nil && ![self.goodModel.comments isEqualToString:@"品牌"]){ if(self.goodModel!=nil && self.goodModel.comments!=nil && ![self.goodModel.comments isEqualToString:@"品牌"]){
self.tbvBrandCaramel.tableHeaderView = [[UIView alloc] initWithFrame:CGRectZero]; self.tbvBrandCaramel.tableHeaderView = [[UIView alloc] initWithFrame:CGRectZero];
} }
if (_backColor) {
_ivBrand.backgroundColor = _backColor;
}else{
[self setBackColor];
}
self.filterView.delegate = self;
self.filterTab.delegate = self;
} }
...@@ -195,26 +166,6 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -195,26 +166,6 @@ static NSString *idStr = @"KWMBrandCaramelCell";
isUp = !isUp; isUp = !isUp;
} }
-(void)onClickSort:(id)sender{
self.vFilter.hidden = NO;
[self initFilterVC];
if(filterVC){
[filterVC setBgImage:[KWMImageBlurUtil getBlurImage:self.tbvBrandCaramel]];
BOOL isSort = YES;
[filterVC setType:isSort];
}
}
-(void)onClickFilter:(id)sender{
self.vFilter.hidden = NO;
[self initFilterVC];
if(filterVC){
[filterVC setBgImage:[KWMImageBlurUtil getBlurImage:self.tbvBrandCaramel]];
BOOL isSort = YES;
[filterVC setType:!isSort];
}
}
//动画 筛选显示:0:不显示 1:显示 2:没有 //动画 筛选显示:0:不显示 1:显示 2:没有
- (void)changeFrameBy:(NSInteger)value WithImageName:(NSString *)imageStr AndShowView:(NSInteger)showNum{ - (void)changeFrameBy:(NSInteger)value WithImageName:(NSString *)imageStr AndShowView:(NSInteger)showNum{
...@@ -233,40 +184,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -233,40 +184,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
}]; }];
} }
-(void)clickRightButton{
if(self.isLoading){
return;
}
self.filterView.hidden = !self.filterView.hidden;
self.filterView.collectionSort = self.collectionSort;
if(self.filterView.hidden){
rightButton.titleLabel.text = @"排序 +";
[rightButton setTitle:@"排序 +" forState:UIControlStateNormal];
}else{
rightButton.titleLabel.text = @"排序 -";
[rightButton setTitle:@"排序 -" forState:UIControlStateNormal];
}
}
-(void)kwm_onCancelFilter{
self.vFilter.hidden = YES;
}
-(void)kwm_onClickSort:(BUYCollectionSort)sort{
self.hasNextPage = YES;
self.collectionSort = sort;
[self reLoadData];
}
-(void)kwm_onHide{
if(self.filterView.hidden){
rightButton.titleLabel.text = @"排序 +";
[rightButton setTitle:@"排序 +" forState:UIControlStateNormal];
}else{
[rightButton setTitle:@"排序 -" forState:UIControlStateNormal];
rightButton.titleLabel.text = @"排序 -";
}
}
#pragma mark -- KWMBarandSelectViewDelegate #pragma mark -- KWMBarandSelectViewDelegate
//点击返回按钮回调 //点击返回按钮回调
...@@ -281,6 +199,28 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -281,6 +199,28 @@ static NSString *idStr = @"KWMBrandCaramelCell";
[self.navigationController pushViewController:shopCartVC animated:YES]; [self.navigationController pushViewController:shopCartVC animated:YES];
} }
#pragma mark -- KWMFilterDelegate
-(void)kwm_onFilterFinish:(KWMFilterView *)filterView{
self.filterView.hidden = YES;
[self.filterTab close];
[self reLoadData];
[self.tbvBrandCaramel.mj_header beginRefreshing];
[self.tbvBrandCaramel setContentOffset:CGPointMake(0,0) animated:YES];
}
-(void)kwm_onClickFilterBlank:(KWMFilterView *)filterView{
[self.filterTab close];
}
#pragma mark -- KWMNormalFilterTabDelegate
-(void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL)isExpand{
self.filterView.filterMode = filterMode;
if(isExpand){
[self.filterView show];
}
self.filterView.hidden = !isExpand;
}
#pragma mark -- KWMBrandCaramelCellDelegate #pragma mark -- KWMBrandCaramelCellDelegate
//点击左边商品回调 //点击左边商品回调
...@@ -397,40 +337,38 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -397,40 +337,38 @@ static NSString *idStr = @"KWMBrandCaramelCell";
- (void)getProcduct:(NSNumber *)collectionId{ - (void)getProcduct:(NSNumber *)collectionId{
BUYCollectionSort collectionSort = self.collectionSort;
if(collectionId == nil){ if(collectionId == nil){
return; return;
} }
__weak KWMBrandCaramelVC *weakSelf = self; __weak KWMBrandCaramelVC *weakSelf = self;
NSInteger tagetPage = self.currentPage.integerValue + 1; //初始化排序及筛选tag
BUYCollectionSort collectionSort = self.filterView.selectedSort;
NSArray *tags = nil; NSMutableArray *tags = [KWMFilterUtil getTagsByFilterArray:self.filterView.selectedTags];
if(self.isSale){ if(self.isSale){
NSString *tag; [tags addObject:@"sale"];
tag = @"sale";
tags = [NSArray arrayWithObjects:tag, nil];
} }
NSInteger tagetPage = self.currentPage.integerValue + 1;
[self.client getProductsPage:tagetPage inCollection:collectionId withTags:tags sortOrder:collectionSort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){ [self.client getProductsPage:tagetPage inCollection:collectionId withTags:tags sortOrder:collectionSort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
products = [products rx_filterWithBlock:^BOOL(BUYProduct *each) { products = [products rx_filterWithBlock:^BOOL(BUYProduct *each) {
return each.availableValue; return each.availableValue;
}]; }];
if (error != nil) { if (error) {
[self showError:error]; [self showError:error];
NSLog(@"Error fetching products: %@", error); NSLog(@"Error fetching products: %@", error);
}else if (products.count == 0 && weakSelf.dataList.count == 0){ }else if (products.count == 0 && tagetPage == 1){
_vNoneGoods.hidden = NO; weakSelf.vNoneGoods.hidden = NO;
[weakSelf.dataList removeAllObjects];
[self.tbvBrandCaramel reloadData];
}else if (error == nil && products) { }else if (error == nil && products) {
if(tagetPage == 1){ if(tagetPage == 1 && (tags.count == 0 || (tags.count == 1 && weakSelf.isSale)) ){
[weakSelf.userDao saveCollectionCache:products collectionId:collectionId tags:tags]; [weakSelf.userDao saveCollectionCache:products collectionId:collectionId tags:tags];
} }
weakSelf.hasNextPage = !reachedEnd; weakSelf.hasNextPage = !reachedEnd;
[weakSelf appendDataList:products setPage:page]; [weakSelf appendDataList:products setPage:page];
_vNoneGoods.hidden = YES; weakSelf.vNoneGoods.hidden = YES;
[self.tbvBrandCaramel reloadData]; [self.tbvBrandCaramel reloadData];
} }
[weakSelf hideLoading]; [weakSelf hideLoading];
......
...@@ -291,40 +291,71 @@ ...@@ -291,40 +291,71 @@
- (void)showError:(NSError *)error{ - (void)showError:(NSError *)error{
if ([error.domain isEqualToString:NSURLErrorDomain]) { if ([error.domain isEqualToString:NSURLErrorDomain]) {
[self showToast:@"网络已断开,请重新连接"]; [self showToast:@"网络已断开,请重新连接"];
// [self showToast:@"请求数据失败"];
return; return;
} }
// NSDictionary *userInfo = [error userInfo]; if (!error.userInfo){
// if (userInfo != nil) {
// NSNumber *errorCodeKey = [userInfo objectForKey:@"_kCFStreamErrorCodeKey"];
// if (errorCodeKey.intValue == 8) {
// [self showToast:@"网络已断开,请重新连接"];
// return;
// }
// }
NSArray<BUYError *> *errors = [BUYError errorsFromCheckoutJSON:error.userInfo];
if([self checkBuyErrors:errors]){
return; return;
} }
errors = [BUYError errorsFromSignUpJSON:error.userInfo]; if ([self isCheckOutError:error]){
if([self checkBuyErrors:errors]){
return; return;
} }
NSString *toast = [self getErrorMessage:error]; if ([self isSignUpError:error]){
if(![KWMStringUtil isEmpty:toast]){ return;
[self showToast:toast]; }
if ([self isNormalError:error]){
return; return;
} }
toast = [self getErrorMessage2:error]; //如果并不是shopify error,则正常吐司。
[self showToast:[error localizedDescription]];
}
-(BOOL)isCheckOutError:(NSError *)error{
//虽然errorsFromCheckoutJSON里面有判断了,但为了保险起见,还是加上判断
NSDictionary *errorsDictionary = error.userInfo[@"errors"];
if(!errorsDictionary || ![errorsDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSDictionary *customerDictionary = errorsDictionary[@"checkout"];
if(!customerDictionary || ![customerDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSArray<BUYError *> *errors = [BUYError errorsFromCheckoutJSON:error.userInfo];
// 现在下单时不会报quantity错误了。所以这段代码注释
// if(errors && errors.count > 0){
// NSString *quantityRemainingMessage = [errors.firstObject quantityRemainingMessage];
// }
if([self checkBuyErrors:errors]){
return YES;
}
return NO;
}
-(BOOL)isSignUpError:(NSError *)error{
NSDictionary *errorsDictionary = error.userInfo[@"errors"];
if(!errorsDictionary || ![errorsDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSDictionary *customerDictionary = errorsDictionary[@"customer"];
if(!customerDictionary || ![customerDictionary isKindOfClass:[NSDictionary class]]){
return NO;
}
NSArray<BUYError *> *errors = [BUYError errorsFromSignUpJSON:error.userInfo];
if([self checkBuyErrors:errors]){
return YES;
}
return NO;
}
- (BOOL)isNormalError:(NSError *)error{
NSString *toast = [self getErrorMessage:error];
if(![KWMStringUtil isEmpty:toast]){ if(![KWMStringUtil isEmpty:toast]){
if(toast!=nil && [toast isEqualToString:@"Unidentified customer"]){ if([toast isEqualToString:@"Unidentified customer"]){
toast = @"登录已失效,请重新登录"; toast = @"登录已失效,请重新登录";
} }
[self showToast:toast]; [self showToast:toast];
return; return YES;
} }
return NO;
[self showToast:[error localizedDescription]];
} }
//判断buyerror是否有效,有效则吐司错误 //判断buyerror是否有效,有效则吐司错误
...@@ -350,18 +381,26 @@ ...@@ -350,18 +381,26 @@
return NO; return NO;
} }
//获取key为message的错误信息 //获取key为message/error的错误信息
- (NSString *)getErrorMessage:(NSError *)error{ - (NSString *)getErrorMessage:(NSError *)error{
return [self getErrorMessageForKey:@"message = \"" error:error]; NSString *errorString;
} errorString = [self getErrorMessageForKey:@"message = \"" error:error];
if(![KWMStringUtil isEmpty:errorString]){
//获取key为error的错误信息 return errorString;
- (NSString *)getErrorMessage2:(NSError *)error{ }
return [self getErrorMessageForKey:@"error = \"" error:error]; errorString = [self getErrorMessageForKey:@"error = \"" error:error];
if(![KWMStringUtil isEmpty:errorString]){
return errorString;
}
errorString = [self getErrorMessageForKey:@"errors = \"" error:error];
if(![KWMStringUtil isEmpty:errorString]){
return errorString;
}
return @"";
} }
-(NSString *)getErrorMessageForKey:(NSString *)key error:(NSError *)error{ -(NSString *)getErrorMessageForKey:(NSString *)key error:(NSError *)error{
NSString *errorString = [self dictionaryToJson:error.userInfo]; NSString *errorString = [self dictionaryToString:error.userInfo];
NSRange startRange = [errorString rangeOfString:key]; NSRange startRange = [errorString rangeOfString:key];
if (startRange.location != NSNotFound) { if (startRange.location != NSNotFound) {
NSString *errorString2 = [errorString substringFromIndex:startRange.location + startRange.length]; NSString *errorString2 = [errorString substringFromIndex:startRange.location + startRange.length];
...@@ -378,13 +417,13 @@ ...@@ -378,13 +417,13 @@
} }
//字典转换为字符串 //字典转换为字符串
- (NSString*)dictionaryToJson:(NSDictionary *)dic{ - (NSString*)dictionaryToString:(NSDictionary *)dic{
NSString *a = [NSString stringWithFormat:@"%@",dic]; NSString *a = [NSString stringWithFormat:@"%@",dic];
return a; return a;
} }
- (BOOL)hasError:(id)result{
- (BOOL)hasError:(id)result{
NSInteger code = -1; NSInteger code = -1;
NSString *message; NSString *message;
if ([result isKindOfClass:[KWMRequestResult class]]) { if ([result isKindOfClass:[KWMRequestResult class]]) {
......
//
// KWMFilterView.h
// iCemarose
//
// Created by HouWeiBin on 2016/12/9.
// Copyright © 2016年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Buy/Buy.h"
@protocol KWMFilterDelegate <NSObject>
- (void)kwm_onClickSort:(BUYCollectionSort)sort;
- (void)kwm_onHide;
@end
@interface KWMFilterView : UIView
@property (weak, nonatomic) IBOutlet UIView *vContent;
@property (weak, nonatomic) IBOutlet UIButton *btnNewToOld;
@property (weak, nonatomic) IBOutlet UIButton *btnDearToCheap;
@property (weak, nonatomic) IBOutlet UIButton *btnCheapToDear;
@property (weak, nonatomic) id<KWMFilterDelegate>delegate;
- (IBAction)onClikcNewToOld:(id)sender;
- (IBAction)onClickDearToCheap:(id)sender;
-(IBAction)onClickCheapToDear:(id)sender;
-(IBAction)onClickBg:(id)sender;
-(IBAction)onClickComplete:(id)sender;
@property (nonatomic) BUYCollectionSort collectionSort;
@end
//
// KWMFilterView.m
// iCemarose
//
// Created by HouWeiBin on 2016/12/9.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMFilterView.h"
#import "UIColor+SAMAdditions.h"
@implementation KWMFilterView
- (id)init{
if (self=[super init]){
[self addView];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self addView];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame{
if (self =[super initWithFrame:frame]) {
[self addView];
}
return self;
}
-(void)awakeFromNib{
[super awakeFromNib];
}
-(void) addView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vContent];
[self initView];
}
-(void)setCollectionSort:(BUYCollectionSort)collectionSort{
if(collectionSort == BUYCollectionSortPriceDescending){
[self onClickDearToCheap:nil];
}else if(collectionSort == BUYCollectionSortPriceAscending){
[self onClickCheapToDear:nil];
}else{
[self onClikcNewToOld:nil];
}
}
-(void)initView{
[self initButton:self.btnNewToOld];
[self initButton:self.btnCheapToDear];
[self initButton:self.btnDearToCheap];
[self setButtonSelect:self.btnNewToOld isSelect:YES];
}
-(void)initButton:(UIButton *)button{
[button.layer setMasksToBounds:YES];
button.layer.cornerRadius = 1; //圆角(圆形)
button.layer.borderColor = [UIColor blackColor].CGColor; //要设置的颜色
button.layer.borderWidth = 1; //要设置的描边宽
}
-(void)setButtonSelect:(UIButton *)button isSelect:(BOOL)isSelect{
if(isSelect){
//设置背景颜色
button.backgroundColor = [UIColor sam_colorWithHex:@"393939"];
button.titleLabel.textColor = [UIColor sam_colorWithHex:@"ffffff"];
[button setTitleColor:[UIColor sam_colorWithHex:@"ffffff"] forState:UIControlStateNormal];
}else{
button.backgroundColor = [UIColor sam_colorWithHex:@"ffffff"];
[button setTitleColor:[UIColor sam_colorWithHex:@"4c5966"] forState:UIControlStateNormal];
}
}
-(void)onClikcNewToOld:(id)sender{
[self setButtonSelect:self.btnNewToOld isSelect:YES];
[self setButtonSelect:self.btnDearToCheap isSelect:NO];
[self setButtonSelect:self.btnCheapToDear isSelect:NO];
_collectionSort = BUYCollectionSortCreatedDescending;
}
-(void)onClickDearToCheap:(id)sender{
[self setButtonSelect:self.btnNewToOld isSelect:NO];
[self setButtonSelect:self.btnDearToCheap isSelect:YES];
[self setButtonSelect:self.btnCheapToDear isSelect:NO];
_collectionSort = BUYCollectionSortPriceDescending;
}
-(void)onClickCheapToDear:(id)sender{
[self setButtonSelect:self.btnNewToOld isSelect:NO];
[self setButtonSelect:self.btnDearToCheap isSelect:NO];
[self setButtonSelect:self.btnCheapToDear isSelect:YES];
_collectionSort = BUYCollectionSortPriceAscending;
}
-(void)onClickBg:(id)sender{
self.hidden = YES;
if(self.delegate!=nil){
[self.delegate kwm_onHide];
}
}
-(void)onClickComplete:(id)sender{
self.hidden = YES;
if(self.delegate!=nil){
[self.delegate kwm_onClickSort:_collectionSort];
[self.delegate kwm_onHide];
}
}
@end
...@@ -9,12 +9,13 @@ ...@@ -9,12 +9,13 @@
#import "KWMBasePageVC.h" #import "KWMBasePageVC.h"
#import "KWMProductType.h" #import "KWMProductType.h"
#import "KWMDoubleTitleView.h" #import "KWMDoubleTitleView.h"
#import "KWMFilterView.h"
#import "KWMBrandCaramelCell.h" #import "KWMBrandCaramelCell.h"
#import "UIColor+SAMAdditions.h" #import "UIColor+SAMAdditions.h"
#import "KWMNormalFilterTab.h"
#import "KWMNormalFilterView.h"
//选中的商品列表 //选中的商品列表
@interface KWMSelectedGoodsVC : KWMBasePageVC<KWMBrandCaramelCellDelegate,KWMFilterDelegate> @interface KWMSelectedGoodsVC : KWMBasePageVC<KWMBrandCaramelCellDelegate,KWMNormalFilterTabDelegate,KWMFilterDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tbvSelectedGoods; @property (weak, nonatomic) IBOutlet UITableView *tbvSelectedGoods;
...@@ -24,14 +25,10 @@ ...@@ -24,14 +25,10 @@
@property (weak, nonatomic) IBOutlet UIView *vHeard; @property (weak, nonatomic) IBOutlet UIView *vHeard;
@property (weak, nonatomic) IBOutlet KWMDoubleTitleView *vDoubleTitle; @property (weak, nonatomic) IBOutlet UIView *vNoData;
@property (weak, nonatomic) IBOutlet KWMFilterView *filterView; @property (weak, nonatomic) IBOutlet KWMNormalFilterTab *filterTab;
@property (weak, nonatomic) IBOutlet KWMNormalFilterView *filterView;
@property (weak, nonatomic) IBOutlet UIImageView *testImageView;
//双重标题view的高度
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightDoubleTitle;
@property (nonatomic) BOOL isLoading; @property (nonatomic) BOOL isLoading;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#import "KWMProductDetailVC.h" #import "KWMProductDetailVC.h"
#import "KWMBeforePayVC.h" #import "KWMBeforePayVC.h"
#import "KWMMineTitleView.h" #import "KWMMineTitleView.h"
#import "MJRefresh.h"
#import "KWMFilterUtil.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
#import "KWMImageBlurUtil.h" #import "KWMImageBlurUtil.h"
...@@ -47,8 +49,9 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -47,8 +49,9 @@ static NSString *idStr = @"KWMBrandCaramelCell";
} }
- (void)initView{ - (void)initView{
self.hasNextPage = NO;
self.collectionSort = BUYCollectionSortCreatedDescending; self.collectionSort = BUYCollectionSortCreatedDescending;
self.filterView.delegate = self;
if(self.productType != nil){ if(self.productType != nil){
//初始化双行标题栏 //初始化双行标题栏
NSString *mTitle; NSString *mTitle;
...@@ -69,22 +72,14 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -69,22 +72,14 @@ static NSString *idStr = @"KWMBrandCaramelCell";
openPosition = -1; openPosition = -1;
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
rightButton =[UIButton buttonWithType:UIButtonTypeRoundedRect];
rightButton.frame = CGRectMake(0, 5, 40, 20);
[rightButton addTarget:self action:@selector(clickRightButton) forControlEvents:UIControlEventTouchUpInside];
[rightButton setTitle:@"排序 +" forState:UIControlStateNormal];
UIBarButtonItem *button =[[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.navigationItem.rightBarButtonItem = button;
rightButton.titleLabel.font=[UIFont systemFontOfSize:11];
[rightButton.layer setMasksToBounds:YES];
rightButton.layer.cornerRadius = 1; //圆角(圆形)
rightButton.layer.borderColor = [UIColor sam_colorWithHex:@"4E4E4E"].CGColor; //要设置的颜色
rightButton.layer.borderWidth = 1; //要设置的描边宽
isSelect = NO; isSelect = NO;
vStopTap = [[UIView alloc] initWithFrame:CGRectMake(0, 20, UI_SCREEN_WIDTH, 44)]; vStopTap = [[UIView alloc] initWithFrame:CGRectMake(0, 20, UI_SCREEN_WIDTH, 44)];
vStopTap.backgroundColor = [UIColor clearColor]; vStopTap.backgroundColor = [UIColor clearColor];
_vHeard.backgroundColor = [UIColor sam_colorWithHex:@"F4F5F7"]; _vHeard.backgroundColor = [UIColor sam_colorWithHex:@"F4F5F7"];
self.filterView.delegate = self;
self.filterTab.delegate = self;
[self initCacheData]; [self initCacheData];
} }
...@@ -119,59 +114,17 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -119,59 +114,17 @@ static NSString *idStr = @"KWMBrandCaramelCell";
} }
} }
-(void)clickRightButton{
// UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:self.testImageView.frame];
// toolBar.barStyle = UIBarStyleDefault;
// [self.view addSubview:toolBar];
// UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
// UIVisualEffectView *view = [[UIVisualEffectView alloc]initWithEffect:beffect];
// view.frame = self.testImageView.frame;
// [self.view addSubview:view];
if(self.isLoading){
return;
}
self.filterView.hidden = !self.filterView.hidden;
self.filterView.collectionSort = self.collectionSort;
if(self.filterView.hidden){
rightButton.titleLabel.text = @"排序 +";
[rightButton setTitle:@"排序 +" forState:UIControlStateNormal];
}else{
[rightButton setTitle:@"排序 -" forState:UIControlStateNormal];
rightButton.titleLabel.text = @"排序 -";
}
}
-(void)kwm_onClickSort:(BUYCollectionSort)sort{
self.hasNextPage = YES;
self.collectionSort = sort;
[self reLoadData];
}
-(void)kwm_onHide{
if(self.filterView.hidden){
rightButton.titleLabel.text = @"排序 +";
[rightButton setTitle:@"排序 +" forState:UIControlStateNormal];
}else{
rightButton.titleLabel.text = @"排序 -";
[rightButton setTitle:@"排序 -" forState:UIControlStateNormal];
}
}
-(UITableView *)targetTableView{ -(UITableView *)targetTableView{
return self.tbvSelectedGoods; return self.tbvSelectedGoods;
} }
-(void)loadData{ -(void)loadData{
[self requesProductList:self.collectionSort]; [self requestProductList];
} }
-(void)reLoadData{ -(void)reLoadData{
self.currentPage = 0; self.currentPage = 0;
[self requesProductList:self.collectionSort]; [self requestProductList];
} }
...@@ -188,6 +141,26 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -188,6 +141,26 @@ static NSString *idStr = @"KWMBrandCaramelCell";
}]; }];
} }
#pragma mark -- KWMFilterDelegate
-(void)kwm_onFilterFinish:(KWMFilterView *)filterView{
self.filterView.hidden = YES;
[self.filterTab close];
[self reLoadData];
[self.tbvSelectedGoods.mj_header beginRefreshing];
[self.tbvSelectedGoods setContentOffset:CGPointMake(0,0) animated:YES];
}
-(void)kwm_onClickFilterBlank:(KWMFilterView *)filterView{
[self.filterTab close];
}
#pragma mark -- KWMNormalFilterTabDelegate
-(void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL)isExpand{
self.filterView.hidden = !isExpand;
self.filterView.filterMode = filterMode;
}
#pragma mark -- KWMBrandCaramelCellDelegate #pragma mark -- KWMBrandCaramelCellDelegate
//点击左边商品回调 //点击左边商品回调
...@@ -265,14 +238,8 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -265,14 +238,8 @@ static NSString *idStr = @"KWMBrandCaramelCell";
return (UI_SCREEN_WIDTH/2 - 20 + 64); return (UI_SCREEN_WIDTH/2 - 20 + 64);
} }
- (void)requesProductList:(BUYCollectionSort)collectionSort{ - (void)requestProductList{
if(!self.hasNextPage){
[self showToast:NSLocalizedString(@"WarnLastPage", @"WarnLastPage")];
[self hideLoading];
return;
}
NSNumber *collectionId; NSNumber *collectionId;
NSArray *tags;
if([TestModel isEqualToString:@"YES"]){ if([TestModel isEqualToString:@"YES"]){
//测试 //测试
self.collection = [[BUYCollection alloc] init]; self.collection = [[BUYCollection alloc] init];
...@@ -281,29 +248,31 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -281,29 +248,31 @@ static NSString *idStr = @"KWMBrandCaramelCell";
if(self.collection!=nil){ if(self.collection!=nil){
collectionId = self.collection.identifier; collectionId = self.collection.identifier;
} }
//初始化排序及筛选tag
BUYCollectionSort collectionSort = self.filterView.selectedSort;
NSMutableArray *tags = [KWMFilterUtil getTagsByFilterArray:self.filterView.selectedTags];
if(self.productType!=nil){ if(self.productType!=nil){
if(![KWMStringUtil isEmpty:self.productType.collectionId]){ if(![KWMStringUtil isEmpty:self.productType.collectionId]){
NSInteger num = [self.productType.collectionId integerValue]; NSInteger num = [self.productType.collectionId integerValue];
collectionId = @(num); collectionId = @(num);
} }
NSString *tag;
if(self.tagType == 0){ if(self.tagType == 0){
tag = @"baby"; [tags addObject:@"baby"];
}else if(self.tagType == 1){ }else if(self.tagType == 1){
tag = @"girls"; [tags addObject:@"girls"];
}else if(self.tagType == 2){ }else if(self.tagType == 2){
tag = @"boys"; [tags addObject:@"boys"];
}else if(self.tagType == 3){ }else if(self.tagType == 3){
tag = @"shoes"; [tags addObject:@"shoes"];
} }
tags = [NSArray arrayWithObjects:tag, nil];
} }
if(collectionId == nil){ if(collectionId == nil){
return; return;
} }
[self showLoading];
self.isLoading = YES; self.isLoading = YES;
__weak KWMSelectedGoodsVC *weakSelf = self; __weak KWMSelectedGoodsVC *weakSelf = self;
NSInteger tagetPage = self.currentPage.integerValue + 1; NSInteger tagetPage = self.currentPage.integerValue + 1;
...@@ -313,11 +282,20 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -313,11 +282,20 @@ static NSString *idStr = @"KWMBrandCaramelCell";
[weakSelf hideLoading]; [weakSelf hideLoading];
if(tagetPage == 1){ if(tagetPage == 1){
if(tags.count == 1){
[weakSelf.userDao saveCollectionCache:products collectionId:collectionId tags:tags]; [weakSelf.userDao saveCollectionCache:products collectionId:collectionId tags:tags];
} }
if(!products || products.count == 0){
self.vNoData.hidden = NO;
[weakSelf.dataList removeAllObjects];
[weakSelf.tbvSelectedGoods reloadData];
return;
}
}
weakSelf.isLoading = NO; weakSelf.isLoading = NO;
if (error == nil && products) { if (error == nil && products) {
self.vNoData.hidden = YES;
weakSelf.hasNextPage = !reachedEnd; weakSelf.hasNextPage = !reachedEnd;
[weakSelf appendDataList:products setPage:page]; [weakSelf appendDataList:products setPage:page];
} }
......
...@@ -45,6 +45,17 @@ ...@@ -45,6 +45,17 @@
-(void)initTextField{ -(void)initTextField{
//http://www.cocoachina.com/bbs/read.php?tid-250044-page-8.html #78
//tf为无边框模式时,输入中文会导致文字下沉的问题。
self.tfName.borderStyle = UITextBorderStyleNone;
self.tfPhone.borderStyle = UITextBorderStyleNone;
self.tfCountry.borderStyle = UITextBorderStyleNone;
self.tfProvince.borderStyle = UITextBorderStyleNone;
self.tfCity.borderStyle = UITextBorderStyleNone;
self.tfAddress.borderStyle = UITextBorderStyleNone;
self.tfAddressDetail.borderStyle = UITextBorderStyleNone;
self.tfZip.borderStyle = UITextBorderStyleNone;
self.tfName.delegate = self; self.tfName.delegate = self;
self.tfPhone.delegate = self; self.tfPhone.delegate = self;
self.tfCountry.delegate = self; self.tfCountry.delegate = self;
......
//
// KWMFilterUtil.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "KWMFilter.h"
@interface KWMFilterUtil : NSObject
+(NSString *) transformTag:(KWMFilter *) filter tag:(NSString *)tag;
+(NSMutableArray<NSString *>*) getTagsByFilterArray:(NSArray<KWMFilter *>*)filterArray;
@end
//
// KWMFilterUtil.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMFilterUtil.h"
#import "KWMFilter.h"
#import "KWMStringUtil.h"
@implementation KWMFilterUtil
+(NSMutableArray<NSString *> *)getTagsByFilterArray:(NSArray<KWMFilter *> *)filterArray{
NSMutableArray<NSString *> *tags = [NSMutableArray array];
for(KWMFilter *filter in filterArray){
if(filter.tags){
for(NSString *tag in filter.tags){
[tags addObject:[self transformTag:filter tag:tag]];
}
}
}
return tags;
}
+(NSString *)transformTag:(KWMFilter *)filter tag:(NSString *)tag{
NSString *mTag = [tag copy];
//"Spring/Summer 2017" => Spring-Summer-2017
if([filter.group isEqualToString:@"SEASON"]){
mTag = [mTag stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
return [tag stringByReplacingOccurrencesOfString:@" " withString:@"-"];
}
//1 month=> size-01m
else if([filter.group isEqualToString:@"SIZE"]){
//不合规则的区别待遇
if([tag isEqualToString:@"0 month"]){
return @"size-0m";
}else if([tag isEqualToString:@"3 month"]){
return @"size-3m";
}else if([tag isEqualToString:@"3 month"]){
return @"size-9m";
}
NSString *numberString = [self getNumberString:tag];
numberString = numberString.length == 1 ? [NSString stringWithFormat:@"0%@",numberString]:numberString;
if([tag rangeOfString:@"year"].location == NSNotFound){
return [NSString stringWithFormat:@"size-%@m",numberString];
}else{
return [NSString stringWithFormat:@"size-%@a",numberString];
}
}
//12 => shoe-size-1
else if([filter.group isEqualToString:@"Shoe Size"]){
return [NSString stringWithFormat:@"shoe-size-%@",tag];
}
//Trousers & Shorts => trousers-shorts
else if([filter.group isEqualToString:@"PRODUCT TYPE"]){
return [KWMStringUtil deleteOtherCharExceptLetterWithLine:tag];
}
return mTag;
}
+(NSString *)getNumberString:(NSString *)string{
NSCharacterSet* nonDigits =[[NSCharacterSet decimalDigitCharacterSet] invertedSet];
return [string stringByTrimmingCharactersInSet:nonDigits];
}
@end
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
+(NSString *) dateformatToHours:(long long) time; +(NSString *) dateformatToHours:(long long) time;
+(CGSize)boundingRectWithSize:(CGSize)size text:(NSString *)text testSize:(CGFloat) testSize; +(CGSize)boundingRectWithSize:(CGSize)size text:(NSString *)text testSize:(CGFloat) testSize;
+(CGSize)getLabelWidth:(NSString *)text labelFont:(UIFont *)aLabelFont textHeight:(CGFloat) textHeight; +(CGSize)getLabelWidth:(NSString *)text labelFont:(UIFont *)aLabelFont textHeight:(CGFloat) textHeight;
+(CGSize)getLabelHeight:(NSString *)text labelFont:(UIFont *)aLabelFont textWidth:(CGFloat) textWidth;
+(NSString *)dateFormatTimeString:(long long)time; +(NSString *)dateFormatTimeString:(long long)time;
+(NSString *)deleteBlankForString:(NSString *)text; +(NSString *)deleteBlankForString:(NSString *)text;
+(NSNumber *)stringToNumber:(NSString *)numberString; +(NSNumber *)stringToNumber:(NSString *)numberString;
......
...@@ -389,6 +389,20 @@ static NSDateFormatter *monthDayFormatter; ...@@ -389,6 +389,20 @@ static NSDateFormatter *monthDayFormatter;
return rect.size; return rect.size;
} }
//计算文本内容的高度
+(CGSize)getLabelHeight:(NSString *)text labelFont:(UIFont *)aLabelFont textWidth:(CGFloat) textWidth{
CGSize constraint = CGSizeMake(textWidth, MAXFLOAT);
CGRect rect = [text boundingRectWithSize:constraint
options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
attributes:@{
NSFontAttributeName : aLabelFont
}
context:nil];
return rect.size;
}
//删除出字母以外的字符补充为@"-" //删除出字母以外的字符补充为@"-"
static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; static NSString *kEnglishNum = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ (NSString *)deleteOtherCharExceptLetterWithLine:(NSString *)str{ + (NSString *)deleteOtherCharExceptLetterWithLine:(NSString *)str{
......
//
// KWMFilterTab.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KWMFilterView.h"
@class KWMFilterTabItem;
@protocol FilterTabItemDelegate <NSObject>
- (void)kwm_onClickTabItem:(KWMFilterTabItem *)item isExpandView:(BOOL) isExpand;
@end
@interface KWMFilterTabItem : UIView
@property(nonatomic,weak) id<FilterTabItemDelegate> delegate;
@property(nonatomic) KWMFilterMode filterMode;
@property(nonatomic) BOOL isExpand;
@end
//
// KWMFilterTab.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMFilterTabItem.h"
#import "UIColor+SAMAdditions.h"
@interface KWMFilterTabItem()
@property(nonatomic,weak) IBOutlet UIView *containerView;
@property(nonatomic,weak) IBOutlet UILabel *lbTitle;
@property(nonatomic,weak) IBOutlet UIImageView *ivArrow;
-(IBAction)onClickTab:(id)sender;
@end
@implementation KWMFilterTabItem
-(void)awakeFromNib{
[super awakeFromNib];
[self initView];
}
-(void)initView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.containerView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.containerView];
self.filterMode = ModeFilter;
}
-(void)setFilterMode:(KWMFilterMode)filterMode{
_filterMode = filterMode;
if(filterMode == ModeFilter){
self.lbTitle.text = @"筛选";
}else if(filterMode == ModeSort){
self.lbTitle.text = @"排序";
}else if(filterMode == ModeBrand){
self.lbTitle.text = @"品牌";
}
}
-(void)onClickTab:(id)sender{
if(self.delegate != nil){
[self.delegate kwm_onClickTabItem:self isExpandView:!self.isExpand];
}
}
-(void)setIsExpand:(BOOL)isExpand{
_isExpand = isExpand;
if(isExpand){
self.lbTitle.textColor = [UIColor sam_colorWithHex:@"F1929A"];
[self.ivArrow setTransform:CGAffineTransformMakeRotation(M_PI)];
}else{
self.lbTitle.textColor = [UIColor sam_colorWithHex:@"515151"];
[self.ivArrow setTransform:CGAffineTransformMakeRotation(0)];
}
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMFilterTabItem">
<connections>
<outlet property="containerView" destination="iN0-l3-epB" id="4uJ-11-hEK"/>
<outlet property="ivArrow" destination="1wv-Qf-Mpm" id="yVW-0M-4Mr"/>
<outlet property="lbTitle" destination="XKx-az-aVp" id="fwZ-S3-5SU"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="188" height="30"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="X29-gf-6cs">
<rect key="frame" x="0.0" y="0.0" width="188" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="筛选" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XKx-az-aVp">
<rect key="frame" x="79.5" y="0.0" width="29" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_arrow_down" translatesAutoresizingMaskIntoConstraints="NO" id="1wv-Qf-Mpm">
<rect key="frame" x="108.5" y="0.0" width="15" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="15" id="8q0-rm-EbE"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<gestureRecognizers/>
<constraints>
<constraint firstItem="1wv-Qf-Mpm" firstAttribute="leading" secondItem="XKx-az-aVp" secondAttribute="trailing" id="B0g-2J-cmY"/>
<constraint firstItem="1wv-Qf-Mpm" firstAttribute="top" secondItem="X29-gf-6cs" secondAttribute="top" id="BQe-6Z-CzL"/>
<constraint firstAttribute="bottom" secondItem="XKx-az-aVp" secondAttribute="bottom" id="ERZ-D0-O2D"/>
<constraint firstAttribute="centerX" secondItem="XKx-az-aVp" secondAttribute="centerX" id="FG6-97-cCo"/>
<constraint firstItem="XKx-az-aVp" firstAttribute="top" secondItem="X29-gf-6cs" secondAttribute="top" id="Wex-w2-URJ"/>
<constraint firstAttribute="bottom" secondItem="1wv-Qf-Mpm" secondAttribute="bottom" id="s9e-lu-b26"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="X29-gf-6cs" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="Ghd-H3-FZ6"/>
<constraint firstAttribute="trailing" secondItem="X29-gf-6cs" secondAttribute="trailing" id="UPA-c4-Vvd"/>
<constraint firstAttribute="bottom" secondItem="X29-gf-6cs" secondAttribute="bottom" id="nLy-LP-Ubo"/>
<constraint firstItem="X29-gf-6cs" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="oTe-ex-8Bj"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outletCollection property="gestureRecognizers" destination="etY-WT-T62" appends="YES" id="Mmr-Wn-3Rk"/>
</connections>
</view>
<tapGestureRecognizer id="etY-WT-T62" userLabel="tapContainer">
<connections>
<action selector="onClickTab:" destination="-1" id="Swg-04-MCg"/>
</connections>
</tapGestureRecognizer>
</objects>
<resources>
<image name="ic_arrow_down" width="6" height="5"/>
</resources>
</document>
//
// KWMFilterView.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KWMFilter.h"
#import <Buy/Buy.h>
typedef NS_ENUM(NSInteger, KWMFilterMode) {
ModeFilter,
ModeSort,
ModeBrand //品牌筛选
};
@class KWMFilterView;
@protocol KWMFilterDelegate <NSObject>
@required
- (void)kwm_onFilterFinish:(KWMFilterView *)filterView;
@optional
- (void)kwm_onClickFilterBlank:(KWMFilterView *)filterView;
@end
@interface KWMFilterView : UIView<UICollectionViewDelegate,UICollectionViewDataSource>
@property(nonatomic) KWMFilterMode filterMode;
@property(nonatomic) NSMutableArray<KWMFilter *> *selectedTags;
@property(nonatomic) BUYCollectionSort selectedSort;
@property(nonatomic,weak) id<KWMFilterDelegate> delegate;
@end
//
// KWMFilterView.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMFilterView.h"
#import "KWMFilterViewCell.h"
#import "UIColor+SAMAdditions.h"
#import "KWMStringUtil.h"
static NSString *filterDataString = @"[{\"group\":\"SEASON\",\"tags\":[\"Spring/Summer 2017\",\"Autumn/Winter 2016\",\"Spring/Summer 2016\",\"Autumn/Winter 2015\"]},{\"group\":\"GENDER\",\"tags\":[\"Girls\",\"Boys\"]},{\"group\":\"SIZE\",\"tags\":[\"0 month\",\"3 month\",\"6 month\",\"9 month\",\"12 month\",\"18 month\",\"2 year\",\"3 year\",\"4 year\",\"5 year\",\"6 year\",\"7 year\",\"8 year\",\"10 year\",\"12 year\",\"14 year\",\"16 year\"]},{\"group\":\"Shoe Size\",\"tags\":[\"18\",\"19\",\"20\",\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"30\",\"31\",\"32\",\"33\",\"34\",\"35\",\"37\",\"38\",\"39\"]},{\"group\":\"PRODUCT TYPE\",\"tags\":[\"Accessories\",\"Babysuits\",\"Coats & Jackets\",\"Dresses\",\"Leggings\",\"Raincoat\",\"Sets\",\"Shoes\",\"Skirts\",\"Swimwear\",\"Tights\",\"Tops\",\"Toys\",\"Trousers & Shorts\",\"Underwear\"]}]";
@interface KWMFilterView()
@property(weak,nonatomic) IBOutlet UIView *vContent;
@property(weak,nonatomic) IBOutlet UICollectionView *cvFilter;
//默认为0 新-旧款 1-3依次对应 旧-新款 高-低价 低-高价
@property(nonatomic) NSInteger selectedSortPosition;
-(IBAction)onClickFilter:(id)sender;
@end
@implementation KWMFilterView{
NSArray<KWMFilter *>*filterData;
NSArray *sortData;
NSArray<NSString *>*sortStringData;
}
-(instancetype)initWithFrame:(CGRect)frame{
if(self = [super initWithFrame:frame]){
[self initView];
}
return self;
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
if(self = [super initWithCoder:aDecoder]){
[self initView];
}
return self;
}
//初始化
-(void)initView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([KWMFilterView class]) owner:self options:nil];
self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vContent];
[self.cvFilter registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionViewHeader"];
[self.cvFilter registerNib:[UINib nibWithNibName:NSStringFromClass([KWMFilterViewCell class]) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass([KWMFilterViewCell class])];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 10;
layout.headerReferenceSize =CGSizeMake(UI_SCREEN_WIDTH - 80,40);//头视图大小
self.cvFilter.collectionViewLayout = layout;
[self initFilterData];
[self initSortData];
self.filterMode = ModeFilter;
self.selectedTags = [NSMutableArray array];
}
-(void)initFilterData{
NSData *data = [filterDataString dataUsingEncoding:NSUTF8StringEncoding];
NSArray *filterDataArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
for(NSDictionary *itemJson in filterDataArray){
NSError *error;
id result = [[KWMFilter alloc] initWithDictionary:itemJson error:&error];
if(error){
NSLog(@"buildListData error: %@", [error localizedDescription]);
}else{
[mutableArray addObject:result];
}
}
filterData = [mutableArray copy];
}
-(void)initSortData{
sortStringData = @[@"新-旧款",@"旧-新款",@"高-低价",@"低-高价"];
}
-(BUYCollectionSort)selectedSort{
switch (self.selectedSortPosition) {
case 0:
return BUYCollectionSortCreatedDescending;
case 1:
return BUYCollectionSortCreatedAscending;
case 2:
return BUYCollectionSortPriceDescending;
case 3:
return BUYCollectionSortPriceAscending;
default:
return BUYCollectionSortCreatedDescending;
}
}
-(void)setSelectedTags:(NSMutableArray<KWMFilter *> *)selectedTags{
_selectedTags = selectedTags ? selectedTags:[NSMutableArray array];
[self.cvFilter reloadData];
}
-(void)setFilterMode:(KWMFilterMode)filterMode{
_filterMode = filterMode;
[self.cvFilter reloadData];
}
-(void)onClickFilter:(id)sender{
if(self.delegate){
[self.delegate kwm_onFilterFinish:self];
}
}
//是否选中tag
-(BOOL)isSelectedTag:(KWMFilter *)filter tag:(NSString *)tag{
for(KWMFilter *addedfilter in self.selectedTags){
if([addedfilter.group isEqualToString:filter.group]){
if([addedfilter.tags containsObject:tag]){
return YES;
}
}
}
return NO;
}
//根据点击的tag,来判断应添加tag到选中数据中,还是应将其从选中数据中移除
-(void)refreshSelectedTags:(KWMFilter *)filter tag:(NSString *)tag{
for(KWMFilter *addedfilter in self.selectedTags){
if([addedfilter.group isEqualToString:filter.group]){
if([addedfilter.tags containsObject:tag]){
[addedfilter.tags removeObject:tag];
}else{
[addedfilter.tags addObject:tag];
}
return;
}
}
KWMFilter *mFilter = [filter copy];
[mFilter.tags removeAllObjects];
[mFilter.tags addObject:tag];
[self.selectedTags addObject:mFilter];
}
#pragma mark - UICollectionViewDataSource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
NSInteger count = self.filterMode == ModeFilter?filterData.count:1;
return count;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
NSUInteger count = self.filterMode == ModeFilter?filterData[section].tags.count:4;
return count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
KWMFilterViewCell *filterCell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([KWMFilterViewCell class]) forIndexPath:indexPath];
//更新cell
if(self.filterMode == ModeFilter){
KWMFilter *filter = filterData[indexPath.section];
NSString *tag = filter.tags[indexPath.row];
filterCell.text = tag;
filterCell.isSelectedFilter = [self isSelectedTag:filter tag:tag];
}else if(self.filterMode == ModeSort){
filterCell.text = sortStringData[indexPath.row];
filterCell.isSelectedFilter = self.selectedSortPosition == indexPath.row;
}
return filterCell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
//默认宽高
CGFloat defaultWidth = (UI_SCREEN_WIDTH - 40 * 2 - 13 * 2)/3;
CGFloat defaultHeight = 36;
//获得cell要显示的文字
NSString *text = @"";
if(self.filterMode == ModeFilter){
KWMFilter *filter = filterData[indexPath.section];
text = filter.tags[indexPath.row];
}
//获得字体,计算文字显示所需高度
UIFont *font = [UIFont systemFontOfSize:12];
if(SYSTEM_VERSION_LESS_THAN(@"9.0")){
[UIFont fontWithName:@"PingFang SC" size:12];
}
CGFloat height = [KWMStringUtil getLabelHeight:text labelFont:font textWidth:defaultWidth - 10].height ;
//返回控件实际大小
//Trousers & Shorts 该项与其他项无法对齐,目前暂不清楚是什么原因...只能通过略微加大宽度来减少视觉上的负面影响。
if([text isEqualToString:@"Trousers & Shorts"]){
return CGSizeMake(defaultWidth+5, fmaxf(height + 10,defaultHeight));
}
return CGSizeMake(defaultWidth, fmaxf(height + 10,defaultHeight));
}
//创建头视图
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath {
UICollectionReusableView *headView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionViewHeader" forIndexPath:indexPath];
UILabel *headerLabel = [headView viewWithTag:101];
//如果是新创建的headView,向其中添加label
if(!headerLabel){
headerLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 15, UI_SCREEN_WIDTH-80,20)];
headerLabel.textColor = [UIColor sam_colorWithHex:@"393939"];
headerLabel.font = [UIFont systemFontOfSize:12];
headerLabel.tag = 101;
[headView addSubview:headerLabel];
}
//更新label
if(self.filterMode == ModeFilter){
KWMFilter *filter = filterData[indexPath.section];
headerLabel.text = filter.group;
}else{
headerLabel.text = @"排序";
}
return headView;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
if(self.filterMode == ModeFilter){
KWMFilter *filter = filterData[indexPath.section];
NSString *tag = filter.tags[indexPath.row];
[self refreshSelectedTags:filter tag:tag];
}else if(self.filterMode == ModeSort){
self.selectedSortPosition = indexPath.row;
}
[self.cvFilter reloadData];
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMFilterView">
<connections>
<outlet property="cvFilter" destination="xOq-Lu-NIJ" id="U2m-de-kD1"/>
<outlet property="vContent" destination="iN0-l3-epB" id="xRL-Ao-DqI"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="431"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jbD-Fx-Doz">
<rect key="frame" x="0.0" y="0.0" width="375" height="431"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mv7-mA-PiS">
<rect key="frame" x="20" y="361" width="335" height="50"/>
<color key="backgroundColor" red="0.14901960784313725" green="0.14901960784313725" blue="0.14901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="ewu-ud-emW"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="15"/>
<state key="normal" title="完成">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onClickFilter:" destination="-1" eventType="touchUpInside" id="hvL-GN-Vs9"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SS1-pG-lvf">
<rect key="frame" x="0.0" y="350" width="375" height="1"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="eO9-gv-xHP"/>
</constraints>
</view>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="xOq-Lu-NIJ">
<rect key="frame" x="40" y="0.0" width="295" height="350"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="N25-Te-Dke">
<size key="itemSize" width="50" height="50"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<connections>
<outlet property="dataSource" destination="-1" id="81u-Yl-hQT"/>
<outlet property="delegate" destination="-1" id="0mY-mW-rnL"/>
</connections>
</collectionView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="SS1-pG-lvf" firstAttribute="leading" secondItem="jbD-Fx-Doz" secondAttribute="leading" id="A0q-lS-woK"/>
<constraint firstItem="mv7-mA-PiS" firstAttribute="leading" secondItem="jbD-Fx-Doz" secondAttribute="leading" constant="20" id="CaG-Z1-dTJ"/>
<constraint firstItem="xOq-Lu-NIJ" firstAttribute="top" secondItem="jbD-Fx-Doz" secondAttribute="top" id="GYK-SV-0Ev"/>
<constraint firstItem="SS1-pG-lvf" firstAttribute="top" secondItem="xOq-Lu-NIJ" secondAttribute="bottom" id="JHJ-KK-0i2"/>
<constraint firstAttribute="trailing" secondItem="xOq-Lu-NIJ" secondAttribute="trailing" constant="40" id="Jeg-y1-yfx"/>
<constraint firstAttribute="trailing" secondItem="mv7-mA-PiS" secondAttribute="trailing" constant="20" id="OaW-Ep-cX1"/>
<constraint firstAttribute="trailing" secondItem="SS1-pG-lvf" secondAttribute="trailing" id="YNA-rc-FJJ"/>
<constraint firstItem="mv7-mA-PiS" firstAttribute="top" secondItem="SS1-pG-lvf" secondAttribute="bottom" constant="10" id="ZW9-sx-06t"/>
<constraint firstAttribute="bottom" secondItem="mv7-mA-PiS" secondAttribute="bottom" constant="20" id="vN3-kk-0IM"/>
<constraint firstItem="xOq-Lu-NIJ" firstAttribute="leading" secondItem="jbD-Fx-Doz" secondAttribute="leading" constant="40" id="w6Z-wB-o3f"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="trailing" secondItem="jbD-Fx-Doz" secondAttribute="trailing" id="Fk5-nZ-ZTP"/>
<constraint firstItem="jbD-Fx-Doz" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="Onf-1J-q5f"/>
<constraint firstItem="jbD-Fx-Doz" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="Trp-bn-hke"/>
<constraint firstAttribute="bottom" secondItem="jbD-Fx-Doz" secondAttribute="bottom" id="eiy-V8-WZa"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="33.5" y="114.5"/>
</view>
</objects>
</document>
//
// KWMFilterViewCell.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface KWMFilterViewCell : UICollectionViewCell
@property (nonatomic) BOOL isSelectedFilter;
@property (nonatomic) NSString *text;
@end
//
// KWMFilterViewCell.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMFilterViewCell.h"
#import "UIColor+SAMAdditions.h"
#import "UIView+Prettify.h"
@interface KWMFilterViewCell()
@property (weak,nonatomic) IBOutlet UIView *vContent;
@property (weak,nonatomic) IBOutlet UILabel *lbDetail;
@end
@implementation KWMFilterViewCell{
}
- (void)awakeFromNib {
[super awakeFromNib];
[self.vContent setBorder:1 cornerRadius:0 borderColor:[UIColor sam_colorWithHex:@"393939"]];
}
-(void)setIsSelectedFilter:(BOOL)isSelectedFilter{
_isSelectedFilter = isSelectedFilter;
if(isSelectedFilter){
self.lbDetail.textColor = [UIColor whiteColor];
self.vContent.backgroundColor = [UIColor sam_colorWithHex:@"393939"];
}else{
self.lbDetail.textColor = [UIColor sam_colorWithHex:@"393939"];
self.vContent.backgroundColor = [UIColor whiteColor];
}
}
-(void)setText:(NSString *)text{
self.lbDetail.text = text?text:@"";
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="KWMFilterViewCell">
<rect key="frame" x="0.0" y="0.0" width="91" height="36"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="91" height="36"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ozs-fo-IBI">
<rect key="frame" x="0.0" y="0.0" width="91" height="36"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="秋冬2015" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Pf-Wf-jVh">
<rect key="frame" x="5" y="0.0" width="81" height="36"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.22352941176470587" green="0.22352941176470587" blue="0.22352941176470587" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="0Pf-Wf-jVh" firstAttribute="leading" secondItem="ozs-fo-IBI" secondAttribute="leading" constant="5" id="CJr-Lw-1sS"/>
<constraint firstAttribute="bottom" secondItem="0Pf-Wf-jVh" secondAttribute="bottom" id="Euw-RL-X6j"/>
<constraint firstItem="0Pf-Wf-jVh" firstAttribute="top" secondItem="ozs-fo-IBI" secondAttribute="top" id="HGc-uo-Pih"/>
<constraint firstAttribute="trailing" secondItem="0Pf-Wf-jVh" secondAttribute="trailing" constant="5" id="l7I-jk-UTD"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstAttribute="bottom" secondItem="ozs-fo-IBI" secondAttribute="bottom" id="1Hx-R9-h15"/>
<constraint firstAttribute="trailing" secondItem="ozs-fo-IBI" secondAttribute="trailing" id="N7x-CL-fQG"/>
<constraint firstItem="ozs-fo-IBI" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="VG6-xI-suF"/>
<constraint firstItem="ozs-fo-IBI" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="Zwb-zC-ovC"/>
</constraints>
<connections>
<outlet property="lbDetail" destination="0Pf-Wf-jVh" id="nrM-KX-3Q3"/>
<outlet property="vContent" destination="ozs-fo-IBI" id="sQw-Sd-zy3"/>
</connections>
</collectionViewCell>
</objects>
</document>
//
// KWMNormalFilterTab.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KWMFilterTabItem.h"
@protocol KWMNormalFilterTabDelegate <NSObject>
- (void)kwm_onClickTab:(KWMFilterMode)filterMode isExpandView:(BOOL) isExpand;
@end
@interface KWMNormalFilterTab : UIView<FilterTabItemDelegate>
@property(nonatomic,weak) id<KWMNormalFilterTabDelegate> delegate;
-(void)close;
@end
//
// KWMNormalFilterTab.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMNormalFilterTab.h"
#import "KWMFilterTabItem.h"
@interface KWMNormalFilterTab()
@property(nonatomic,weak) IBOutlet UIView *containerView;
@property(nonatomic,weak) IBOutlet KWMFilterTabItem *vLeft;
@property(nonatomic,weak) IBOutlet KWMFilterTabItem *vRight;
@end
@implementation KWMNormalFilterTab
-(void)awakeFromNib{
[super awakeFromNib];
[self initView];
}
-(void)initView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.containerView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
self.backgroundColor = [UIColor redColor];
[self addSubview:self.containerView];
self.vLeft.filterMode = ModeFilter;
self.vRight.filterMode = ModeSort;
self.vLeft.delegate = self;
self.vRight.delegate = self;
}
-(void)kwm_onClickTabItem:(KWMFilterTabItem *)item isExpandView:(BOOL)isExpand{
self.vLeft.isExpand = item.filterMode == ModeFilter? isExpand: NO;
self.vRight.isExpand = item.filterMode == ModeSort? isExpand: NO;
if(self.delegate){
[self.delegate kwm_onClickTab:item.filterMode isExpandView:isExpand];
}
}
-(void)close{
self.vLeft.isExpand = NO;
self.vRight.isExpand = NO;
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12120"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMNormalFilterTab">
<connections>
<outlet property="containerView" destination="iN0-l3-epB" id="btB-pv-WTY"/>
<outlet property="vLeft" destination="SlH-TR-5Jd" id="UMx-8j-Rmg"/>
<outlet property="vRight" destination="Zym-UK-hE9" id="5HR-sc-5ah"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="30"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LuV-Yr-gBK">
<rect key="frame" x="0.0" y="0.0" width="375" height="30"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="niD-9D-3MP">
<rect key="frame" x="0.0" y="0.0" width="375" height="30"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SlH-TR-5Jd" userLabel="vLeft" customClass="KWMFilterTabItem">
<rect key="frame" x="0.0" y="0.0" width="186.5" height="30"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zym-UK-hE9" userLabel="vRight" customClass="KWMFilterTabItem">
<rect key="frame" x="187.5" y="0.0" width="187.5" height="30"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cNw-Hg-ifw" userLabel="vMidLine">
<rect key="frame" x="186.5" y="5" width="1" height="20"/>
<color key="backgroundColor" red="0.94509803921568625" green="0.5725490196078431" blue="0.60392156862745094" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="LFK-yW-WER"/>
<constraint firstAttribute="height" constant="20" id="iCR-rK-nTf"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UTV-01-O0q">
<rect key="frame" x="0.0" y="29" width="375" height="1"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="hcy-0b-OH8"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="cNw-Hg-ifw" firstAttribute="centerY" secondItem="niD-9D-3MP" secondAttribute="centerY" id="1Q4-53-h8q"/>
<constraint firstItem="UTV-01-O0q" firstAttribute="leading" secondItem="niD-9D-3MP" secondAttribute="leading" id="4fs-NC-Pmf"/>
<constraint firstItem="cNw-Hg-ifw" firstAttribute="leading" secondItem="SlH-TR-5Jd" secondAttribute="trailing" id="4vk-Tx-4Ha"/>
<constraint firstItem="SlH-TR-5Jd" firstAttribute="leading" secondItem="niD-9D-3MP" secondAttribute="leading" id="CDn-j9-ObI"/>
<constraint firstAttribute="bottom" secondItem="SlH-TR-5Jd" secondAttribute="bottom" id="CMS-82-bOw"/>
<constraint firstAttribute="trailing" secondItem="Zym-UK-hE9" secondAttribute="trailing" id="HZI-ss-IJR"/>
<constraint firstItem="Zym-UK-hE9" firstAttribute="top" secondItem="niD-9D-3MP" secondAttribute="top" id="LDd-7G-HYl"/>
<constraint firstAttribute="bottom" secondItem="UTV-01-O0q" secondAttribute="bottom" id="WaW-39-fOB"/>
<constraint firstAttribute="trailing" secondItem="UTV-01-O0q" secondAttribute="trailing" id="dai-nt-KBh"/>
<constraint firstItem="Zym-UK-hE9" firstAttribute="leading" secondItem="cNw-Hg-ifw" secondAttribute="trailing" id="fsa-71-cRm"/>
<constraint firstItem="cNw-Hg-ifw" firstAttribute="centerX" secondItem="niD-9D-3MP" secondAttribute="centerX" id="myE-jB-XyF"/>
<constraint firstItem="SlH-TR-5Jd" firstAttribute="top" secondItem="niD-9D-3MP" secondAttribute="top" id="qfr-Fe-drH"/>
<constraint firstAttribute="bottom" secondItem="Zym-UK-hE9" secondAttribute="bottom" id="ubg-Bm-VCZ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.95686274509803915" green="0.96078431372549022" blue="0.96862745098039216" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="niD-9D-3MP" firstAttribute="top" secondItem="LuV-Yr-gBK" secondAttribute="top" id="B35-Gh-HUH"/>
<constraint firstItem="niD-9D-3MP" firstAttribute="leading" secondItem="LuV-Yr-gBK" secondAttribute="leading" id="bXh-Fv-MwB"/>
<constraint firstAttribute="bottom" secondItem="niD-9D-3MP" secondAttribute="bottom" id="kBS-Ha-BHH"/>
<constraint firstAttribute="trailing" secondItem="niD-9D-3MP" secondAttribute="trailing" id="oBo-P7-HJ0"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="LuV-Yr-gBK" secondAttribute="trailing" id="B8a-Nc-07q"/>
<constraint firstItem="LuV-Yr-gBK" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="GOW-rL-l2N"/>
<constraint firstItem="LuV-Yr-gBK" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="O8L-Vm-Qjt"/>
<constraint firstAttribute="bottom" secondItem="LuV-Yr-gBK" secondAttribute="bottom" id="UfQ-OM-vVm"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="89.5" y="108.5"/>
</view>
</objects>
</document>
//
// KWMNormalFilterView.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KWMFilterView.h"
@interface KWMNormalFilterView : UIView
@property(nonatomic) KWMFilterMode filterMode;
@property(nonatomic,weak) id<KWMFilterDelegate> delegate;
@property(nonatomic) NSMutableArray<KWMFilter *> *selectedTags;
@property(nonatomic) BUYCollectionSort selectedSort;
-(void)show;
@end
//
// KWMTopFilterView.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/8.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMNormalFilterView.h"
@interface KWMNormalFilterView()
@property(weak,nonatomic) IBOutlet UIView *vContent;
@property(weak,nonatomic) IBOutlet KWMFilterView *filterView;
@property(weak,nonatomic) IBOutlet NSLayoutConstraint *heightFilter;
@property(weak,nonatomic) IBOutlet NSLayoutConstraint *marginTopFilter;
-(IBAction)onClickBlank:(id)sender;
@end
@implementation KWMNormalFilterView
-(instancetype)initWithFrame:(CGRect)frame{
if(self = [super initWithFrame:frame]){
[self initView];
}
return self;
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
if(self = [super initWithCoder:aDecoder]){
[self initView];
}
return self;
}
//初始化
-(void)initView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vContent];
}
-(void)setFilterMode:(KWMFilterMode)filterMode{
_filterMode = filterMode;
self.filterView.filterMode = filterMode;
self.heightFilter.constant = filterMode == ModeFilter?self.frame.size.height * 0.7:210;
}
-(void)setDelegate:(id<KWMFilterDelegate>)delegate{
_delegate = delegate;
self.filterView.delegate = delegate;
}
-(BUYCollectionSort)selectedSort{
return self.filterView.selectedSort;
}
-(NSMutableArray<KWMFilter *> *)selectedTags{
return self.filterView.selectedTags;
}
-(void)onClickBlank:(id)sender{
if(self.delegate && [self.delegate respondsToSelector:@selector(kwm_onClickFilterBlank:)]){
[self.delegate kwm_onClickFilterBlank:self.filterView];
}
self.hidden = YES;
}
-(void)show{
if(self.hidden){
self.marginTopFilter.constant = -self.heightFilter.constant;
self.hidden = NO;
[self layoutIfNeeded];
[UIView animateWithDuration:self.filterMode == ModeFilter?0.5:0.25 animations:^{
self.marginTopFilter.constant = 0;
[self layoutIfNeeded];
}];
}
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMNormalFilterView">
<connections>
<outlet property="filterView" destination="AFM-lg-PjC" id="pNw-rv-IvA"/>
<outlet property="heightFilter" destination="6KX-Dg-66z" id="Wo3-eH-eHC"/>
<outlet property="marginTopFilter" destination="SiA-l8-az5" id="Azb-Jh-GQP"/>
<outlet property="vContent" destination="iN0-l3-epB" id="7BZ-YQ-Bpg"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vsx-Tb-ugb">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z7B-Ta-Qar" userLabel="Blank">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<connections>
<outletCollection property="gestureRecognizers" destination="XTx-4h-dka" appends="YES" id="BFR-eg-lnB"/>
</connections>
</view>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AFM-lg-PjC" customClass="KWMFilterView">
<rect key="frame" x="0.0" y="0.0" width="375" height="300"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="300" id="6KX-Dg-66z"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="z7B-Ta-Qar" secondAttribute="bottom" id="ARt-a6-IfB"/>
<constraint firstAttribute="trailing" secondItem="z7B-Ta-Qar" secondAttribute="trailing" id="AgG-Je-tFg"/>
<constraint firstItem="z7B-Ta-Qar" firstAttribute="top" secondItem="vsx-Tb-ugb" secondAttribute="top" id="OgI-6M-n7R"/>
<constraint firstItem="z7B-Ta-Qar" firstAttribute="leading" secondItem="vsx-Tb-ugb" secondAttribute="leading" id="QvB-kf-QnC"/>
<constraint firstItem="AFM-lg-PjC" firstAttribute="top" secondItem="vsx-Tb-ugb" secondAttribute="top" id="SiA-l8-az5"/>
<constraint firstItem="AFM-lg-PjC" firstAttribute="leading" secondItem="vsx-Tb-ugb" secondAttribute="leading" id="fsU-Xp-mDE"/>
<constraint firstAttribute="trailing" secondItem="AFM-lg-PjC" secondAttribute="trailing" id="y3m-QH-Uah"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="vsx-Tb-ugb" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="3yR-fD-Fn8"/>
<constraint firstItem="vsx-Tb-ugb" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="AZz-DG-Djx"/>
<constraint firstAttribute="bottom" secondItem="vsx-Tb-ugb" secondAttribute="bottom" id="gps-dw-eNb"/>
<constraint firstAttribute="trailing" secondItem="vsx-Tb-ugb" secondAttribute="trailing" id="ttf-rG-sW2"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
</view>
<tapGestureRecognizer id="XTx-4h-dka" userLabel="tapBlank">
<connections>
<action selector="onClickBlank:" destination="-1" id="7wU-Df-M9v"/>
</connections>
</tapGestureRecognizer>
</objects>
</document>
//
// UIView+Prettify.h
// SchedulePlan
//
// Created by HouWeiBin on 2016/12/23.
// Copyright © 2016年 kollway. All rights reserved.
//
// 用于uiview的装饰,如添加边框,阴影。
#import <UIKit/UIKit.h>
@interface UIView (Prettify)
//设置边框
-(void)setBorder:(CGFloat)width cornerRadius:(CGFloat)cornerRadius borderColor:(UIColor *)borderColor;
//设置阴影
-(void)setShadow:(CGSize)shadowOffset shadowRadius:(CGFloat)shadowRadius shadowOpacity:(CGFloat)shadowOpacity shadowColor:(UIColor *)shadowColor;
//设置默认阴影
-(void)initDefaultShadow;
@end
//
// UIView+Prettify.m
// SchedulePlan
//
// Created by HouWeiBin on 2016/12/23.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "UIView+Prettify.h"
@implementation UIView (Prettify)
-(void)setBorder:(CGFloat)width cornerRadius:(CGFloat)cornerRadius borderColor:(UIColor *)borderColor{
self.layer.cornerRadius = cornerRadius;
self.layer.masksToBounds = YES;
self.layer.borderWidth = width;
self.layer.borderColor = borderColor.CGColor;
}
-(void)setShadow:(CGSize)shadowOffset shadowRadius:(CGFloat)shadowRadius shadowOpacity:(CGFloat)shadowOpacity shadowColor:(UIColor *)shadowColor{
self.layer.shadowColor = shadowColor.CGColor;//shadowColor阴影颜色
self.layer.shadowOffset = shadowOffset;//shadowOffset阴影偏移,x向右偏移,y向下偏移,默认(0, -3),这个跟shadowRadius配合使用
self.layer.shadowOpacity = shadowOpacity;//阴影透明度,默认0
self.layer.shadowRadius = shadowRadius;//阴影半径,默认3
}
-(void)initDefaultShadow{
[self setShadow:CGSizeMake(0,1) shadowRadius:4 shadowOpacity:0.1 shadowColor:[UIColor blackColor]];
}
@end
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define UI_SCREEN_HEITHT ([[UIScreen mainScreen] bounds].size.height) #define UI_SCREEN_HEITHT ([[UIScreen mainScreen] bounds].size.height)
#define KWMAPI_URL(path) [NSURL URLWithString:[[KWMAPIManager sharedManager] toAbsoluteUrl:path]] #define KWMAPI_URL(path) [NSURL URLWithString:[[KWMAPIManager sharedManager] toAbsoluteUrl:path]]
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define KWMTextTips 0 #define KWMTextTips 0
#define KWMNoDataTips 1 #define KWMNoDataTips 1
#define KWMNoLike 2 #define KWMNoLike 2
...@@ -61,7 +62,7 @@ ...@@ -61,7 +62,7 @@
#define Cemarose_KEY @"4a119ac523d53c98bbd2983b798a0d53" #define Cemarose_KEY @"4a119ac523d53c98bbd2983b798a0d53"
// ////
////测试 ////测试
//#define TestModel @"YES" //#define TestModel @"YES"
// //
......
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