Commit 2041dd27 by lee

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

parents 60fa6510 52b1c54f
......@@ -33,5 +33,8 @@ pod 'MagicalRecord','~> 2.2'
pod 'Mobile-Buy-SDK',:git => 'https://github.com/houweibin/mobile-buy-sdk-ios'
#pod 'Mobile-Buy-SDK',:path => '../Pods/mobile-buy-sdk-ios'
pod 'JLRoutes'
pod 'iCarousel', '~> 1.8'
pod 'MagicalRecord','~> 2.2'
pod 'CHTCollectionViewWaterfallLayout', '~> 0.9.5'
end
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_home_about_shipping@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_home_about_shipping@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_home_favorite_product@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_home_favorite_product@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_home_hot_product@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_home_hot_product@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_home_new_product@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_home_new_product@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "test_banner_1@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "test_banner_1@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "test_banner_2@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "test_banner_2@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "test_suit@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "test_suit@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -724,7 +724,7 @@
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="NBO-61-l1q" kind="relationship" relationship="rootViewController" id="0Rm-QP-yVX"/>
<segue destination="NBO-61-l1q" kind="relationship" relationship="rootViewController" id="vPW-jg-RE6"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7Z2-Md-Vzb" userLabel="First Responder" sceneMemberID="firstResponder"/>
......@@ -1193,6 +1193,60 @@
</objects>
<point key="canvasLocation" x="361" y="2035"/>
</scene>
<!--新首页-->
<scene sceneID="6mO-YL-KC8">
<objects>
<viewController storyboardIdentifier="KWMNewHomeVC" useStoryboardIdentifierAsRestorationIdentifier="YES" id="kxV-Ho-iPP" userLabel="新首页" customClass="KWMNewHomeVC" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Iv3-Qt-qCa"/>
<viewControllerLayoutGuide type="bottom" id="7nS-iD-8eZ"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="fiQ-A6-I4g">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="T1z-z9-rlz">
<rect key="frame" x="0.0" y="44" width="375" height="623"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="BcI-5v-hSE">
<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>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="XBe-Y7-KXB">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="kxV-Ho-iPP" id="P4G-75-qA8"/>
<outlet property="delegate" destination="kxV-Ho-iPP" id="5qe-Uz-vxL"/>
</connections>
</collectionView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="T1z-z9-rlz" secondAttribute="trailing" id="0wc-Yi-qru"/>
<constraint firstItem="7nS-iD-8eZ" firstAttribute="top" secondItem="T1z-z9-rlz" secondAttribute="bottom" id="e8Y-7q-Dxx"/>
<constraint firstItem="T1z-z9-rlz" firstAttribute="leading" secondItem="fiQ-A6-I4g" secondAttribute="leading" id="u26-Oo-qx3"/>
<constraint firstItem="T1z-z9-rlz" firstAttribute="top" secondItem="Iv3-Qt-qCa" secondAttribute="bottom" constant="24" id="w7n-oP-oiG"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="xTg-gj-jEd"/>
<connections>
<outlet property="cvHome" destination="T1z-z9-rlz" id="HYR-6b-gcC"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="FmK-HG-RdK" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1169" y="1380"/>
</scene>
</scenes>
<resources>
<image name="button_mine_log out" width="19" height="20"/>
......
//
// KWMAdvertisement.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseModel.h"
@interface KWMAdvertisement : KWMBaseModel
//标题
@property (nonatomic) NSString *title;
//图片地址
@property (nonatomic) NSString *image;
//链接
@property (nonatomic) NSString *url;
@end
//
// KWMAdvertisement.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMAdvertisement.h"
@implementation KWMAdvertisement
@end
//
// KWMHomeData.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseModel.h"
#import "KWMAdvertisement.h"
#import "KWMHotSales.h"
@interface KWMHomeData : KWMBaseModel
@property (nonatomic) NSArray *adBanner;
@property (nonatomic) KWMAdvertisement *clothingSets;
@property (nonatomic) KWMHotSales *hotSales;
@end
//
// KWMHomeData.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMHomeData.h"
@implementation KWMHomeData
@end
//
// KWMHotSales.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseModel.h"
@interface KWMHotSales : KWMBaseModel
//大图商品数量
@property (nonatomic) NSNumber *singleShowCount;
@end
//
// KWMHotSales.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/7.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMHotSales.h"
@implementation KWMHotSales
@end
......@@ -71,7 +71,7 @@
[self initTbvLeft];
[self initCvRight];
self.sort = BUYCollectionSortCreatedAscending;
self.sort = BUYCollectionSortCreatedDescending;
self.selectBrands = @"";
}
......@@ -215,20 +215,18 @@
[tags addObject:self.selectBrands];
}
[self.client getProductsPage:page inCollection:@(171596038) withTags:tags sortOrder:self.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
[self.client getProductsPage:page inCollection:@(Collection_All_ID) withTags:tags sortOrder:self.sort completion:^(NSArray *products,NSUInteger page, BOOL reachedEnd, NSError *error){
[weakSelf.refreshUtil hideLoading];
weakSelf.filterTab.userInteractionEnabled = true;
if(error){
[weakSelf showError:error];
}
else{
weakSelf.refreshUtil.page = page;
weakSelf.refreshUtil.hasNextPage = !reachedEnd;
[weakSelf.refreshUtil appendDataList:products];
}
}];
}
......
......@@ -35,13 +35,13 @@
-(NSInteger)getSelectSortPosition:(BUYCollectionSort)sort{
switch (sort) {
case BUYCollectionSortCreatedAscending:
return 0;
case BUYCollectionSortCreatedDescending:
return 0;
case BUYCollectionSortCreatedAscending:
return 1;
case BUYCollectionSortPriceAscending:
return 2;
case BUYCollectionSortPriceDescending:
return 2;
case BUYCollectionSortPriceAscending:
return 3;
default:
return 0;
......@@ -68,7 +68,7 @@
return self.filterView.selectedTags;
}
-(void)kwm_onClickFilter:(KWMFilterView *)filterView{
-(void)kwm_onFilterFinish:(KWMFilterView *)filterView{
if(self.delegate){
[self.delegate kwm_onCompleProductFilter:filterView];
}
......
//
// KWMAdHeader.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseModel.h"
#import "KWMBannerView.h"
#import "KWMAdvertisement.h"
@protocol KWMAdDelegate <NSObject>
- (void)kwm_gotoWebView:(NSString *)url;
@end
@interface KWMAdHeader : UIView<KWMBannerViewDelegate>
+ (NSString *)kwmTag;
-(void)startBannerTimer;
-(void)endBannerTimer;
@property (nonatomic) NSArray<KWMAdvertisement *> *adArray;
@property(nonatomic,weak) id<KWMAdDelegate> delegate;
@end
//
// KWMAdHeader.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMAdHeader.h"
#import "UIImageView+WebCache.h"
@interface KWMAdHeader()
@property (nonatomic,strong) KWMBannerView *bannerView;
@end
@implementation KWMAdHeader
+(NSString *)kwmTag{
return @"KWMAdHeader";
}
- (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)addView{
self.bannerView = [[KWMBannerView alloc]initWithFrame:self.frame];
self.bannerView.delegate = self;
[self addSubview:self.bannerView];
}
-(void)startBannerTimer{
[self.bannerView addTimer];
}
-(void)endBannerTimer{
[self.bannerView removeTimer];
}
-(void)setAdArray:(NSArray<KWMAdvertisement *> *)adArray{
_adArray = adArray;
[self.bannerView reloadData];
}
#pragma mark - KWMBannerViewDelegate
-(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index{
UIView *itemView = reusingView?reusingView:nil;
UIImageView *topBannerItem = nil;
if(!itemView){
topBannerItem = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, bannerView.frame.size.width, bannerView.frame.size.height)];
}else{
topBannerItem = (UIImageView *)itemView;
}
KWMAdvertisement *ad = [self.adArray objectAtIndex:index];
NSURL *imageURL = [NSURL URLWithString:ad.image];
[topBannerItem sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
//topBannerItem.image = [UIImage imageNamed:@"test_banner_1"];
topBannerItem.contentMode=UIViewContentModeScaleAspectFill;
itemView = topBannerItem;
return itemView;
}
-(NSInteger)numberOfPagesForBanner:(KWMBannerView *)bannerView{
return self.adArray?self.adArray.count:0;
}
-(void)bannerView:(KWMBannerView *)bannerView onClickPage:(NSInteger)index{
KWMAdvertisement *ad = [self.adArray objectAtIndex:index];
if(self.delegate){
[self.delegate kwm_gotoWebView:ad.url];
}
}
@end
//
// KWMSuitCell.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/5.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
@interface KWMClothingSetsCell : UICollectionViewCell
@property(nonatomic) BUYProduct *product;
@end
//
// KWMSuitCell.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/5.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMClothingSetsCell.h"
#import "KWMStringUtil.h"
#import "KWMImageUtil.h"
#import "UIImageView+WebCache.h"
@interface KWMClothingSetsCell()
@property(nonatomic,weak) IBOutlet UILabel *lbName;
@property(nonatomic,weak) IBOutlet UILabel *lbPrice;
@property(nonatomic,weak) IBOutlet UIImageView *ivProduct;
@end
@implementation KWMClothingSetsCell
- (void)awakeFromNib {
[super awakeFromNib];
}
-(void)setProduct:(BUYProduct *)product{
_product = product;
if(product){
NSString *imageUrl = [KWMImageUtil getProductImageUrl:product ImageSize:SmallImage];
NSURL *imageURL = [NSURL URLWithString:imageUrl];
[self.ivProduct sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
self.lbName.text = product.title;
if(product.variantsArray.count>0){
BUYProductVariant *variant = product.variantsArray.firstObject;
self.lbPrice.text = [KWMStringUtil price:variant.price];
}
}
}
@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="Aspect ratio constraints" minToolsVersion="5.1"/>
<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="KWMClothingSetsCell">
<rect key="frame" x="0.0" y="0.0" width="66" height="100"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="66" height="100"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HJW-BD-Yxt">
<rect key="frame" x="0.0" y="0.0" width="66" height="100"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="test_home_cloth_2" translatesAutoresizingMaskIntoConstraints="NO" id="9za-nW-9Xw">
<rect key="frame" x="0.0" y="0.0" width="66" height="66"/>
<constraints>
<constraint firstAttribute="width" secondItem="9za-nW-9Xw" secondAttribute="height" multiplier="1:1" id="0g9-Jd-NWL"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CARAMEL" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yLu-gy-qUp">
<rect key="frame" x="0.0" y="66" width="66" height="15.5"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="11"/>
<color key="textColor" red="0.3411764705882353" green="0.3411764705882353" blue="0.3411764705882353" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥2900" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y7j-iw-wgF">
<rect key="frame" x="0.0" y="81.5" width="31" height="13"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="9"/>
<color key="textColor" red="0.59215686274509804" green="0.59215686274509804" blue="0.59215686274509804" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥2450" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ETG-Ir-uXq">
<rect key="frame" x="35" y="81.5" width="31" height="13"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="9"/>
<color key="textColor" red="0.59215686274509804" green="0.59215686274509804" blue="0.59215686274509804" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Y7j-iw-wgF" firstAttribute="leading" secondItem="HJW-BD-Yxt" secondAttribute="leading" id="5ZM-eJ-GGC"/>
<constraint firstItem="Y7j-iw-wgF" firstAttribute="top" secondItem="yLu-gy-qUp" secondAttribute="bottom" id="BgQ-jF-bdC"/>
<constraint firstAttribute="trailing" secondItem="ETG-Ir-uXq" secondAttribute="trailing" id="Gkl-Fj-jok"/>
<constraint firstAttribute="trailing" secondItem="yLu-gy-qUp" secondAttribute="trailing" id="J6w-IL-OFe"/>
<constraint firstItem="yLu-gy-qUp" firstAttribute="top" secondItem="9za-nW-9Xw" secondAttribute="bottom" id="Sjr-vz-04G"/>
<constraint firstItem="9za-nW-9Xw" firstAttribute="leading" secondItem="HJW-BD-Yxt" secondAttribute="leading" id="WTp-pJ-BqU"/>
<constraint firstAttribute="trailing" secondItem="9za-nW-9Xw" secondAttribute="trailing" id="lNG-tE-Czx"/>
<constraint firstItem="yLu-gy-qUp" firstAttribute="leading" secondItem="HJW-BD-Yxt" secondAttribute="leading" id="qrw-fg-pgo"/>
<constraint firstItem="ETG-Ir-uXq" firstAttribute="top" secondItem="yLu-gy-qUp" secondAttribute="bottom" id="r1H-oy-KBr"/>
<constraint firstItem="9za-nW-9Xw" firstAttribute="top" secondItem="HJW-BD-Yxt" secondAttribute="top" id="r31-zi-pm2"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstAttribute="bottom" secondItem="HJW-BD-Yxt" secondAttribute="bottom" id="4iA-WQ-OGj"/>
<constraint firstAttribute="trailing" secondItem="HJW-BD-Yxt" secondAttribute="trailing" id="MbS-uF-BDP"/>
<constraint firstItem="HJW-BD-Yxt" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="xt9-ym-xFa"/>
<constraint firstItem="HJW-BD-Yxt" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="yXo-lP-ZkK"/>
</constraints>
<size key="customSize" width="84" height="78"/>
<connections>
<outlet property="ivProduct" destination="9za-nW-9Xw" id="o4P-wq-5gE"/>
<outlet property="lbName" destination="yLu-gy-qUp" id="EyX-Dv-lZp"/>
<outlet property="lbPrice" destination="ETG-Ir-uXq" id="gGI-mJ-6Ms"/>
</connections>
<point key="canvasLocation" x="75" y="122"/>
</collectionViewCell>
</objects>
<resources>
<image name="test_home_cloth_2" width="140" height="140"/>
</resources>
</document>
//
// KWMClothingSetsHeader.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
@protocol KWMClothingSetsDelegate <NSObject>
- (void)kwm_onClickProduct:(BUYProduct *)product;
@end
@interface KWMClothingSetsHeader : UIView<UICollectionViewDataSource,UICollectionViewDelegate>
+ (NSString *)kwmTag;
@property(nonatomic,weak) id<KWMClothingSetsDelegate> delegate;
@property(nonatomic) NSArray *productArray;
@property(nonatomic) NSString *headerImage;
@end
//
// KWMClothingSetsHeader.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMClothingSetsHeader.h"
#import "KWMClothingSetsCell.h"
#import "UIImageView+WebCache.h"
@interface KWMClothingSetsHeader()
@property (nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) IBOutlet UICollectionView *cvSets;
@property (nonatomic,weak) IBOutlet UIImageView *ivHeader;
@end
@implementation KWMClothingSetsHeader
+(NSString *)kwmTag{
return @"KWMClothingSetsHeader";
}
- (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)addView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
[self initView];
}
-(void)initView{
self.cvSets.delegate = self;
self.cvSets.dataSource = self;
[self.cvSets registerNib:[UINib nibWithNibName:NSStringFromClass([KWMClothingSetsCell class]) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass([KWMClothingSetsCell class])];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
layout.minimumLineSpacing = 20;
layout.sectionInset = UIEdgeInsetsMake(0, 20, 0, 0);
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
self.cvSets.collectionViewLayout = layout;
}
-(void)setProductArray:(NSArray *)productArray{
_productArray = productArray;
[self.cvSets reloadData];
}
-(void)setHeaderImage:(NSString *)headerImage{
_headerImage = headerImage;
NSURL *imageURL = [NSURL URLWithString:headerImage];
[self.ivHeader sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
}
#pragma mark - UICollectionViewDataSource
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
KWMClothingSetsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([KWMClothingSetsCell class]) forIndexPath:indexPath];
BUYProduct *product = [self.productArray objectAtIndex:indexPath.row];
cell.product = product;
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGSize size = CGSizeMake(66, 100);
return size;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.productArray?self.productArray.count:0;
}
@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="KWMClothingSetsHeader">
<connections>
<outlet property="cvSets" destination="Vrm-Ee-B8d" id="Gd3-Qy-Yyl"/>
<outlet property="ivHeader" destination="Xzr-zM-E25" id="Baj-uk-PJK"/>
<outlet property="vView" destination="iN0-l3-epB" id="lK1-FX-gaB"/>
</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="310"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nBP-0Q-eKB" userLabel="推荐搭配title view">
<rect key="frame" x="0.0" y="0.0" width="375" height="190"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="test_suit" translatesAutoresizingMaskIntoConstraints="NO" id="Xzr-zM-E25">
<rect key="frame" x="0.0" y="0.0" width="375" height="190"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_triangle" translatesAutoresizingMaskIntoConstraints="NO" id="LvJ-FP-Yc1">
<rect key="frame" x="177" y="181" width="20" height="10"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="eNY-P5-Ji7"/>
<constraint firstAttribute="height" constant="10" id="oBh-wd-7za"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" red="0.90588235289999997" green="0.81960784310000001" blue="0.74117647060000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Xzr-zM-E25" firstAttribute="top" secondItem="nBP-0Q-eKB" secondAttribute="top" id="4oD-P2-9Xz"/>
<constraint firstItem="Xzr-zM-E25" firstAttribute="leading" secondItem="nBP-0Q-eKB" secondAttribute="leading" id="Fci-xu-TIa"/>
<constraint firstAttribute="bottom" secondItem="LvJ-FP-Yc1" secondAttribute="bottom" constant="-1" id="SAq-Iw-I6t"/>
<constraint firstAttribute="height" constant="190" id="Ssh-cP-PRt"/>
<constraint firstAttribute="bottom" secondItem="Xzr-zM-E25" secondAttribute="bottom" id="UhQ-tF-lG6"/>
<constraint firstAttribute="trailing" secondItem="Xzr-zM-E25" secondAttribute="trailing" id="dj0-cH-YiI"/>
<constraint firstItem="LvJ-FP-Yc1" firstAttribute="centerX" secondItem="nBP-0Q-eKB" secondAttribute="centerX" id="yqu-ba-mQR"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="d3i-H3-n3M" userLabel="推荐搭配view">
<rect key="frame" x="0.0" y="200" width="375" height="110"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="Vrm-Ee-B8d">
<rect key="frame" x="0.0" y="0.0" width="375" height="110"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="yJj-6q-jus">
<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>
</collectionView>
</subviews>
<color key="backgroundColor" red="0.94509803920000002" green="0.57254901960000004" blue="0.60392156860000001" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Vrm-Ee-B8d" secondAttribute="trailing" id="4Ee-9q-Qw4"/>
<constraint firstItem="Vrm-Ee-B8d" firstAttribute="leading" secondItem="d3i-H3-n3M" secondAttribute="leading" id="QHG-5e-T4g"/>
<constraint firstAttribute="height" constant="110" id="ape-VU-LEB"/>
<constraint firstItem="Vrm-Ee-B8d" firstAttribute="top" secondItem="d3i-H3-n3M" secondAttribute="top" id="sK4-AC-qhp"/>
<constraint firstAttribute="bottom" secondItem="Vrm-Ee-B8d" secondAttribute="bottom" id="wyf-yo-UKD"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="d3i-H3-n3M" firstAttribute="top" secondItem="nBP-0Q-eKB" secondAttribute="bottom" constant="10" id="AWM-jC-Dgh"/>
<constraint firstAttribute="trailing" secondItem="nBP-0Q-eKB" secondAttribute="trailing" id="FsT-9E-ABs"/>
<constraint firstItem="nBP-0Q-eKB" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="Ir3-VU-W52"/>
<constraint firstItem="d3i-H3-n3M" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="eci-1V-z0s"/>
<constraint firstAttribute="trailing" secondItem="d3i-H3-n3M" secondAttribute="trailing" id="miR-QW-5Az"/>
<constraint firstItem="nBP-0Q-eKB" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="onh-Xr-uix"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="34.5" y="107"/>
</view>
</objects>
<resources>
<image name="ic_triangle" width="16" height="16"/>
<image name="test_suit" width="375" height="212"/>
</resources>
</document>
//
// KWMHotSalesHeader.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KWMBannerView.h"
#import <Buy/Buy.h>
@protocol KWMHotSalesDelegate <NSObject>
- (void)kwm_onClickProduct:(BUYProduct *)product;
@end
@interface KWMHotSalesHeader : UIView<KWMBannerViewDelegate>
+ (NSString *)kwmTag;
-(void)startBannerTimer;
-(void)endBannerTimer;
@property(nonatomic,weak) id<KWMHotSalesDelegate> delegate;
@property(nonatomic) NSArray *singleShowArray;
@property(nonatomic) NSArray *bannerArray;
@end
//
// KWMHotSalesHeader.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMHotSalesHeader.h"
#import "KWMProductBannerItemView.h"
#import "UIImageView+WebCache.h"
@interface KWMHotSalesHeader()
@property (nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) IBOutlet KWMBannerView *bannerView;
@end
@implementation KWMHotSalesHeader
+(NSString *)kwmTag{
return @"KWMHotSalesHeader";
}
- (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)addView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
[self initView];
}
-(void)initView{
self.bannerView.delegate = self;
}
-(void)startBannerTimer{
[self.bannerView addTimer];
}
-(void)endBannerTimer{
[self.bannerView removeTimer];
}
#pragma mark - KWMBannerViewDelegate
-(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index{
UIView *itemView = reusingView?reusingView:nil;
KWMProductBannerItemView *productBannerItem = nil;
if(!itemView){
productBannerItem = [[KWMProductBannerItemView alloc]initWithFrame:CGRectMake(0, 0, bannerView.frame.size.width, bannerView.frame.size.height)];
}else{
productBannerItem = (KWMProductBannerItemView *)itemView;
}
itemView = productBannerItem;
return itemView;
}
-(NSInteger)numberOfPagesForBanner:(KWMBannerView *)bannerView{
return 4;
}
-(void)bannerView:(KWMBannerView *)bannerView onClickPage:(NSInteger)index{
}
@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="KWMHotSalesHeader">
<connections>
<outlet property="bannerView" destination="Ruv-UI-DGw" id="USH-xg-KHp"/>
<outlet property="vView" destination="iN0-l3-epB" id="bI2-U9-soo"/>
</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="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="d0n-L5-xP1" userLabel="热卖单品title view">
<rect key="frame" x="0.0" y="10" width="375" height="50"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uhq-ZL-9OL">
<rect key="frame" x="97.5" y="24.5" width="40" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="hzU-8w-40e"/>
<constraint firstAttribute="height" constant="1" id="xaE-u5-Def"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ILX-tg-IwY">
<rect key="frame" x="237.5" y="24.5" width="40" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="Nec-hp-m8B"/>
<constraint firstAttribute="width" constant="40" id="Rei-3E-m0o"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="热卖单品" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eec-tG-wTs">
<rect key="frame" x="159.5" y="15" width="56" height="20"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="14"/>
<color key="textColor" red="0.31764705879999999" green="0.31764705879999999" blue="0.31764705879999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="5Yc-uM-1JE"/>
<constraint firstItem="eec-tG-wTs" firstAttribute="centerY" secondItem="d0n-L5-xP1" secondAttribute="centerY" id="I3v-8v-sbb"/>
<constraint firstItem="uhq-ZL-9OL" firstAttribute="centerY" secondItem="d0n-L5-xP1" secondAttribute="centerY" id="Kd2-sq-d0s"/>
<constraint firstItem="ILX-tg-IwY" firstAttribute="centerX" secondItem="d0n-L5-xP1" secondAttribute="centerX" constant="70" id="ebd-7K-pU1"/>
<constraint firstItem="uhq-ZL-9OL" firstAttribute="centerX" secondItem="d0n-L5-xP1" secondAttribute="centerX" constant="-70" id="fE4-tP-dve"/>
<constraint firstItem="eec-tG-wTs" firstAttribute="centerX" secondItem="d0n-L5-xP1" secondAttribute="centerX" id="kdF-5D-r65"/>
<constraint firstItem="ILX-tg-IwY" firstAttribute="centerY" secondItem="d0n-L5-xP1" secondAttribute="centerY" id="r8p-Ru-bb6"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ruv-UI-DGw" userLabel="热卖单品Banner" customClass="KWMBannerView">
<rect key="frame" x="0.0" y="60" width="375" height="190"/>
<color key="backgroundColor" red="0.90588235289999997" green="0.81960784310000001" blue="0.74117647060000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="190" id="NbW-Kh-s5O"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dwm-lO-Zce" userLabel="singleShowView">
<rect key="frame" x="0.0" y="250" width="375" height="50"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Ruv-UI-DGw" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="9fw-Ph-Q4P"/>
<constraint firstItem="Ruv-UI-DGw" firstAttribute="top" secondItem="d0n-L5-xP1" secondAttribute="bottom" id="BTm-DX-XK4"/>
<constraint firstAttribute="bottom" secondItem="Dwm-lO-Zce" secondAttribute="bottom" id="Kxi-PL-odG"/>
<constraint firstAttribute="trailing" secondItem="Ruv-UI-DGw" secondAttribute="trailing" id="RLP-eB-Asb"/>
<constraint firstItem="d0n-L5-xP1" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="aWf-1E-iKC"/>
<constraint firstItem="d0n-L5-xP1" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="g82-sr-LTG"/>
<constraint firstAttribute="trailing" secondItem="d0n-L5-xP1" secondAttribute="trailing" id="iHt-uY-XiY"/>
<constraint firstAttribute="trailing" secondItem="Dwm-lO-Zce" secondAttribute="trailing" id="q59-1g-wOJ"/>
<constraint firstItem="Dwm-lO-Zce" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="vxZ-CO-Z64"/>
<constraint firstItem="Dwm-lO-Zce" firstAttribute="top" secondItem="Ruv-UI-DGw" secondAttribute="bottom" id="y5m-bf-H2m"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="34.5" y="107"/>
</view>
</objects>
</document>
//
// KWMMenuHeader.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseModel.h"
@protocol KWMMenuDelegate <NSObject>
- (void)kwm_onClickNewMenu;
- (void)kwm_onClickHotMenu;
- (void)kwm_onClickWishMenu;
- (void)kwm_onClickDeliveryMenu;
@end
@interface KWMMenuHeader : UIView
+ (NSString *)kwmTag;
@property(nonatomic,weak) id<KWMMenuDelegate> delegate;
@end
//
// KWMMenuHeader.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMMenuHeader.h"
@interface KWMMenuHeader()
@property (nonatomic,weak) IBOutlet UIView *vView;
@end
@implementation KWMMenuHeader
+(NSString *)kwmTag{
return @"KWMMenuHeader";
}
- (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) addView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
}
@end
//
// KWMNewHomeCell.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/2.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
@interface KWMNewHomeCell : UICollectionViewCell
@property(nonatomic,weak) IBOutlet UIView *vContent;
//文本是否居中
@property(nonatomic) BOOL textAlignCenter;
@property(nonatomic) BUYProduct *product;
+(NSInteger)acturlHeight:(BUYProduct *)product width:(NSInteger)width;
@end
//
// KWMNewHomeCell.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/2.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMNewHomeCell.h"
#import "UIView+Prettify.h"
#import "KWMStringUtil.h"
#import "KWMImageUtil.h"
#import "UIImageView+WebCache.h"
@interface KWMNewHomeCell()
@property(nonatomic,weak) IBOutlet UILabel *lbBrand;
@property(nonatomic,weak) IBOutlet UILabel *lbName;
@property(nonatomic,weak) IBOutlet UILabel *lbPrice;
@property(nonatomic,weak) IBOutlet UIImageView *ivProduct;
@end
@implementation KWMNewHomeCell
- (void)awakeFromNib {
[super awakeFromNib];
[self.vContent initDefaultShadow];
}
-(void)setTextAlignCenter:(BOOL)textAlignCenter{
if(textAlignCenter){
NSTextAlignment textAlignment = textAlignCenter?NSTextAlignmentCenter:NSTextAlignmentLeft;
self.lbBrand.textAlignment = textAlignment;
self.lbName.textAlignment = textAlignment;
self.lbPrice.textAlignment = textAlignment;
self.lbName.numberOfLines = 1;
self.lbBrand.numberOfLines = 1;
}
}
-(void)setProduct:(BUYProduct *)product{
_product = product;
if(product){
NSString *imageUrl = [KWMImageUtil getProductImageUrl:product ImageSize:SmallImage];
NSURL *imageURL = [NSURL URLWithString:imageUrl];
[self.ivProduct sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
self.lbBrand.text = product.vendor;
self.lbName.text = product.title;
if(product.variantsArray.count>0){
BUYProductVariant *variant = product.variantsArray.firstObject;
self.lbPrice.text = [KWMStringUtil price:variant.price];
}
}
}
+(NSInteger)acturlHeight:(BUYProduct *)product width:(NSInteger)width{
NSInteger lbNameWidth = width - 60;
UIFont *font = [UIFont systemFontOfSize:12];
if(SYSTEM_VERSION_LESS_THAN(@"9.0")){
[UIFont fontWithName:@"PingFang SC" size:12];
}
NSInteger lbNameHeight = [KWMStringUtil getLabelHeight:product.title labelFont:font textWidth:lbNameWidth].height;
return 250 - 13 + lbNameHeight;
}
@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="Aspect ratio constraints" minToolsVersion="5.1"/>
<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" tag="1111" contentMode="center" id="gTV-IL-0wX" customClass="KWMNewHomeCell">
<rect key="frame" x="0.0" y="0.0" width="184" height="250"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="184" height="250"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view tag="999" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eUm-tt-XRm">
<rect key="frame" x="0.0" y="0.0" width="184" height="250"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PUL-8B-4lT">
<rect key="frame" x="10" y="10" width="164" height="230"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="test_home_cloth_2" translatesAutoresizingMaskIntoConstraints="NO" id="Yw1-oo-Px9">
<rect key="frame" x="10" y="10" width="144" height="144"/>
<constraints>
<constraint firstAttribute="width" secondItem="Yw1-oo-Px9" secondAttribute="height" multiplier="1:1" id="Plg-nh-9IY"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="EMILE ET IDA" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iip-8b-kmO">
<rect key="frame" x="20" y="174" width="124" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Semibold" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.3411764705882353" green="0.3411764705882353" blue="0.3411764705882353" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Baby Girls Pink Cotton Dress" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VtC-9N-HwV">
<rect key="frame" x="20" y="191" width="124" height="13"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="9"/>
<color key="textColor" red="0.3411764705882353" green="0.3411764705882353" blue="0.3411764705882353" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥245" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I9K-1A-41L">
<rect key="frame" x="20" y="204" width="124" height="15.5"/>
<fontDescription key="fontDescription" name="PingFangSC-Semibold" family="PingFang SC" pointSize="11"/>
<color key="textColor" red="0.94509803921568625" green="0.5725490196078431" blue="0.60392156862745094" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="iip-8b-kmO" firstAttribute="top" secondItem="Yw1-oo-Px9" secondAttribute="bottom" constant="20" id="5x3-U5-Tk4"/>
<constraint firstItem="Yw1-oo-Px9" firstAttribute="top" secondItem="PUL-8B-4lT" secondAttribute="top" constant="10" id="AFL-Yl-vYR"/>
<constraint firstItem="VtC-9N-HwV" firstAttribute="top" secondItem="iip-8b-kmO" secondAttribute="bottom" id="CUr-b2-Mlj"/>
<constraint firstItem="Yw1-oo-Px9" firstAttribute="leading" secondItem="PUL-8B-4lT" secondAttribute="leading" constant="10" id="HHD-Te-aIz"/>
<constraint firstItem="VtC-9N-HwV" firstAttribute="leading" secondItem="PUL-8B-4lT" secondAttribute="leading" constant="20" id="IDU-jP-oLa"/>
<constraint firstAttribute="trailing" secondItem="I9K-1A-41L" secondAttribute="trailing" constant="20" id="MbK-01-xMo"/>
<constraint firstItem="I9K-1A-41L" firstAttribute="leading" secondItem="PUL-8B-4lT" secondAttribute="leading" constant="20" id="UT0-th-1oq"/>
<constraint firstAttribute="trailing" secondItem="Yw1-oo-Px9" secondAttribute="trailing" constant="10" id="VHa-rc-KaE"/>
<constraint firstAttribute="trailing" secondItem="VtC-9N-HwV" secondAttribute="trailing" constant="20" id="Wpj-A5-jni"/>
<constraint firstAttribute="trailing" secondItem="iip-8b-kmO" secondAttribute="trailing" constant="20" id="YCX-w6-xX0"/>
<constraint firstItem="iip-8b-kmO" firstAttribute="leading" secondItem="PUL-8B-4lT" secondAttribute="leading" constant="20" id="b3U-cr-ZDD"/>
<constraint firstItem="I9K-1A-41L" firstAttribute="top" secondItem="VtC-9N-HwV" secondAttribute="bottom" id="hD3-ec-XTJ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="PUL-8B-4lT" secondAttribute="bottom" constant="10" id="1dM-Eh-HNy"/>
<constraint firstItem="PUL-8B-4lT" firstAttribute="leading" secondItem="eUm-tt-XRm" secondAttribute="leading" constant="10" id="7mj-32-Otd"/>
<constraint firstAttribute="trailing" secondItem="PUL-8B-4lT" secondAttribute="trailing" constant="10" id="Gjy-El-ETO"/>
<constraint firstItem="PUL-8B-4lT" firstAttribute="top" secondItem="eUm-tt-XRm" secondAttribute="top" constant="10" id="gle-W7-xpx"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstItem="eUm-tt-XRm" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="Kbh-Gc-SDc"/>
<constraint firstAttribute="trailing" secondItem="eUm-tt-XRm" secondAttribute="trailing" id="c3O-1E-opH"/>
<constraint firstAttribute="bottom" secondItem="eUm-tt-XRm" secondAttribute="bottom" id="l6S-fV-SJb"/>
<constraint firstItem="eUm-tt-XRm" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="zg2-VO-6we"/>
</constraints>
<size key="customSize" width="145" height="199"/>
<connections>
<outlet property="lbBrand" destination="iip-8b-kmO" id="kWY-VC-0aX"/>
<outlet property="lbName" destination="VtC-9N-HwV" id="fk8-4v-a3w"/>
<outlet property="lbPrice" destination="I9K-1A-41L" id="AIn-iA-Kep"/>
<outlet property="vContent" destination="PUL-8B-4lT" id="HaA-xv-gdY"/>
</connections>
<point key="canvasLocation" x="81.5" y="182.5"/>
</collectionViewCell>
</objects>
<resources>
<image name="test_home_cloth_2" width="140" height="140"/>
</resources>
</document>
//
// KWMProductBannerItemView.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/6.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface KWMProductBannerItemView : UIView
@end
//
// KWMProductBannerItemView.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/6.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMProductBannerItemView.h"
@interface KWMProductBannerItemView()
@property(nonatomic,weak) IBOutlet UIView *vContent;
@end
@implementation KWMProductBannerItemView
-(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([KWMProductBannerItemView class]) owner:self options:nil];
self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vContent];
}
@end
//
// KWMRecommendHeader.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
@protocol KWMRecommendDelegate <NSObject>
- (void)kwm_onClickProduct:(BUYProduct *)product;
@end
@interface KWMRecommendHeader : UIView<UICollectionViewDataSource,UICollectionViewDelegate>
+ (NSString *)kwmTag;
@property(nonatomic,weak) id<KWMRecommendDelegate> delegate;
@property(nonatomic) NSArray *productArray;
@end
//
// KWMRecommendHeader.m
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMRecommendHeader.h"
#import "KWMCollectionCell.h"
@interface KWMRecommendHeader()
@property (nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) IBOutlet UICollectionView *cvRecommend;
@end
@implementation KWMRecommendHeader
+(NSString *)kwmTag{
return @"KWMRecommendHeader";
}
- (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)addView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
[self initView];
}
-(void)initView{
self.cvRecommend.delegate = self;
self.cvRecommend.dataSource = self;
[self.cvRecommend registerNib:[UINib nibWithNibName:NSStringFromClass([KWMCollectionCell class]) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass([KWMCollectionCell class])];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 0;
layout.sectionInset = UIEdgeInsetsMake(0, 20, 0, 0);
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
self.cvRecommend.collectionViewLayout = layout;
}
-(void)setProductArray:(NSArray *)productArray{
_productArray = productArray;
[self.cvRecommend reloadData];
}
#pragma mark - UICollectionViewDataSource
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
KWMCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([KWMCollectionCell class]) forIndexPath:indexPath];
BUYProduct *product = [self.productArray objectAtIndex:indexPath.row];
[cell setData:product];
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGSize size = CGSizeMake(134, 180);
return size;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.productArray?self.productArray.count:0;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
BUYProduct *product = [self.productArray objectAtIndex:indexPath.row];
if(self.delegate){
[self.delegate kwm_onClickProduct:product];
}
}
@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="KWMRecommendHeader">
<connections>
<outlet property="cvRecommend" destination="YkQ-i0-Pi8" id="k1I-3x-9pe"/>
<outlet property="vView" destination="iN0-l3-epB" id="4mj-ET-3eS"/>
</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="230"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="INK-4h-HDz" userLabel="主推单品title view">
<rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Oxh-Z4-5Du">
<rect key="frame" x="97.5" y="24.5" width="40" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="dN7-5L-uPZ"/>
<constraint firstAttribute="width" constant="40" id="u4w-ir-uYu"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Fhz-dH-m9M">
<rect key="frame" x="237.5" y="24.5" width="40" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="Q9Q-rN-rC2"/>
<constraint firstAttribute="height" constant="1" id="mTX-4g-wc5"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="主推单品" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Fq-VX-XvA">
<rect key="frame" x="159.5" y="15" width="56" height="20"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="14"/>
<color key="textColor" red="0.31764705879999999" green="0.31764705879999999" blue="0.31764705879999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="7Fq-VX-XvA" firstAttribute="centerY" secondItem="INK-4h-HDz" secondAttribute="centerY" id="GUe-O7-zhD"/>
<constraint firstItem="Oxh-Z4-5Du" firstAttribute="centerY" secondItem="INK-4h-HDz" secondAttribute="centerY" id="ITn-hx-4NT"/>
<constraint firstItem="Fhz-dH-m9M" firstAttribute="centerY" secondItem="INK-4h-HDz" secondAttribute="centerY" id="Kf2-Pe-l0z"/>
<constraint firstItem="7Fq-VX-XvA" firstAttribute="centerX" secondItem="INK-4h-HDz" secondAttribute="centerX" id="dYW-od-kCg"/>
<constraint firstItem="Fhz-dH-m9M" firstAttribute="centerX" secondItem="INK-4h-HDz" secondAttribute="centerX" constant="70" id="i4I-Eo-hi5"/>
<constraint firstItem="Oxh-Z4-5Du" firstAttribute="centerX" secondItem="INK-4h-HDz" secondAttribute="centerX" constant="-70" id="i8R-P6-nyJ"/>
<constraint firstAttribute="height" constant="50" id="oy0-m9-5BJ"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="34o-As-5pe" userLabel="主推单品view">
<rect key="frame" x="0.0" y="50" width="375" height="180"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="YkQ-i0-Pi8">
<rect key="frame" x="0.0" y="0.0" width="375" height="180"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="vfk-q0-t1d">
<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>
</collectionView>
</subviews>
<constraints>
<constraint firstItem="YkQ-i0-Pi8" firstAttribute="top" secondItem="34o-As-5pe" secondAttribute="top" id="4Qd-a8-3pl"/>
<constraint firstItem="YkQ-i0-Pi8" firstAttribute="leading" secondItem="34o-As-5pe" secondAttribute="leading" id="bgA-TL-ipu"/>
<constraint firstAttribute="height" constant="180" id="onq-ka-ELe"/>
<constraint firstAttribute="bottom" secondItem="YkQ-i0-Pi8" secondAttribute="bottom" id="r6l-pn-vDm"/>
<constraint firstAttribute="trailing" secondItem="YkQ-i0-Pi8" secondAttribute="trailing" id="tpm-sS-9NT"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="INK-4h-HDz" secondAttribute="trailing" id="1cJ-MT-eT0"/>
<constraint firstItem="INK-4h-HDz" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="98o-Bp-hPz"/>
<constraint firstItem="34o-As-5pe" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="ALu-k7-LMK"/>
<constraint firstItem="INK-4h-HDz" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="Tbg-nl-U5C"/>
<constraint firstAttribute="trailing" secondItem="34o-As-5pe" secondAttribute="trailing" id="m0q-mr-OrX"/>
<constraint firstItem="34o-As-5pe" firstAttribute="top" secondItem="INK-4h-HDz" secondAttribute="bottom" id="p0w-Sf-0ew"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="34.5" y="107"/>
</view>
</objects>
</document>
//
// KWMNewHomeVC.h
// iCemarose
//
// Created by HouWeiBin on 2017/7/10.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBaseVC.h"
#import "KWMSearchBar.h"
#import <CHTCollectionViewWaterfallLayout.h>
#import "KWMAdHeader.h"
#import "KWMMenuHeader.h"
#import "KWMRecommendHeader.h"
#import "KWMClothingSetsHeader.h"
#import "KWMHotSalesHeader.h"
@interface KWMNewHomeVC : KWMBaseVC<CHTCollectionViewDelegateWaterfallLayout,UICollectionViewDataSource,KWMSearchBarDelegate,KWMAdDelegate,KWMMenuDelegate,KWMRecommendDelegate,KWMClothingSetsDelegate,KWMHotSalesDelegate>
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMNewHomeVC">
<connections>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</objects>
</document>
//
// KWMBannerView.h
// iCemarose
//
// Created by HouWeiBin on 2017/5/31.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <iCarousel/iCarousel.h>
#import "KWMPageControl.h"
@class KWMBannerView;
@protocol KWMBannerViewDelegate <NSObject>
//页面滑动监听
@optional
-(void)bannerView:(KWMBannerView *)bannerView onPageIndexChange:(NSInteger)index;
//更新背景view
-(void)bannerView:(KWMBannerView *)bannerView backgroundView:(UIView *)backgroundView updateBackgroundViewAtIndex:(NSInteger)index;
//更新前景view
-(void)bannerView:(KWMBannerView *)bannerView foregroundView:(UIView *)foregroundView updateForegroundViewAtIndex:(NSInteger)index;
@required
//页面被点击 注意:小心前景view foregroundView挡住事件的情况
-(void)bannerView:(KWMBannerView *)bannerView onClickPage:(NSInteger)index;
//index对应页面view
-(UIView *)bannerView:(KWMBannerView *)bannerView reusingView:(UIView *)reusingView pageAtIndex:(NSInteger)index;
//页数
-(NSInteger)numberOfPagesForBanner:(KWMBannerView *)bannerView;
@end
@interface KWMBannerView : UIView<iCarouselDataSource, iCarouselDelegate>
//backgroundView默认会添加一个,如果不需要定制化,可以直接使用已有的
@property (nonatomic,strong) UIView *backgroundView;
//foregroundView默认会添加一个,如果不需要定制化,可以直接使用已有的
@property (nonatomic,strong) UIView *foregroundView;
@property (nonatomic,assign,readonly) NSInteger pageIndex;
@property(nonatomic,weak) id<KWMBannerViewDelegate> delegate;
-(void)reloadData;
-(void) addTimer;
-(void) removeTimer;
@end
//
// KWMBannerView.m
// iCemarose
//
// Created by HouWeiBin on 2017/5/31.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMBannerView.h"
@implementation KWMBannerView{
iCarousel *carousel;
NSTimer *timer;
BOOL isFirstLoad;
BOOL isScroll;
}
-(void)addTimer{
[self removeTimer];
isFirstLoad = YES;
timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(doTimer) userInfo:nil repeats:YES];
[timer setFireDate:[NSDate distantPast]];//开启
}
-(void)removeTimer{
//结束
if([timer isValid]){
[timer invalidate];
timer = nil;
}
}
-(void)doTimer{
NSInteger pageCount = self.delegate?[self.delegate numberOfPagesForBanner:self]:0;
if(pageCount > 0 && !isScroll){
if(isFirstLoad){ //避免出现第一次显示就是第二页的情况
isFirstLoad = NO;
return;
}
NSInteger currentIndex = self.pageIndex;
currentIndex ++;
[carousel scrollToItemAtIndex:currentIndex animated:YES];
[self updateUIOnPageChange];
}
}
-(instancetype)init{
self = [super init];
if(self){
}
return self;
}
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self initBannerView:frame];
}
return self;
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) {
[self initBannerView:self.frame];
}
return self;
}
-(void)awakeFromNib{
[super awakeFromNib];
}
-(void)setDelegate:(id<KWMBannerViewDelegate>)delegate{
_delegate = delegate;
if(delegate){
[self reloadData];
}
}
-(void)reloadData{
if(carousel){
[carousel reloadData];
}
if(self.foregroundView && self.foregroundView.tag == 1002){
KWMPageControl *pageControl = (KWMPageControl *)self.foregroundView;
//pageControl圆点右对齐
NSInteger count = self.delegate?[self.delegate numberOfPagesForBanner:self]:0;
CGSize pageControlSize = [pageControl sizeForNumberOfPages:count];
CGFloat paddingLeft = (pageControl.bounds.size.width - pageControlSize.width) / 2 - 15;
[pageControl setBounds:CGRectMake(-paddingLeft, pageControl.bounds.origin.y,
pageControl.bounds.size.width, pageControl.bounds.size.height)];
}
}
-(void)initBannerView:(CGRect)frame{
carousel = [[iCarousel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
carousel.delegate = self;
carousel.dataSource = self;
carousel.decelerationRate = 0.5;
carousel.type = iCarouselTypeLinear;
carousel.clipsToBounds = YES;
[self addSubview:carousel];
UIImageView *noDataImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
noDataImageView.contentMode = UIViewContentModeCenter;
UIImage *noDataImage = [UIImage imageNamed:@"ic_logo"];
noDataImageView.image = noDataImage;
noDataImageView.tag = 1001;//用于判断是否默认背景view
self.backgroundView = noDataImageView;
CGRect pageControlFrame = CGRectMake(0, frame.size.height - 20, frame.size.width, 20);
UIImage *defaultImage = [UIImage imageNamed:@"ic_page_1"];
UIImage *currentImage = [UIImage imageNamed:@"ic_page_2"];
KWMPageControl *pageControl = [[KWMPageControl alloc]initWithFrame:pageControlFrame currentImage:currentImage andDefaultImage:defaultImage];
pageControl.numberOfPages = 4;
pageControl.currentPage = 0;
pageControl.tag = 1002;//用于判断是否默认前景view
self.foregroundView = pageControl;
}
-(NSInteger)pageIndex{
if(carousel){
return carousel.currentItemIndex;
}
return 0;
}
-(void)setBackgroundView:(UIView *)backgroundView{
_backgroundView = backgroundView;
UIView *oldBackgroundView = [self viewWithTag:101];
if(oldBackgroundView){
[oldBackgroundView removeFromSuperview];
}
oldBackgroundView = [self viewWithTag:1001];
if(oldBackgroundView){
[oldBackgroundView removeFromSuperview];
}
if(backgroundView){
backgroundView.tag = 101;
[self addSubview:backgroundView];
[self sendSubviewToBack:backgroundView];
}
}
-(void)setForegroundView:(UIView *)foregroundView{
_foregroundView = foregroundView;
UIView *oldForegroundView = [self viewWithTag:102];
if(oldForegroundView){
[oldForegroundView removeFromSuperview];
}
oldForegroundView = [self viewWithTag:1002];
if(oldForegroundView){
[oldForegroundView removeFromSuperview];
}
if(foregroundView){
//设置tag前先判断是否默认foregroundView,以免覆盖了tag
foregroundView.tag = foregroundView.tag == 1002?1002:102;
[self addSubview:foregroundView];
[self bringSubviewToFront:foregroundView];
}
}
-(void)updateUIOnPageChange{
if(self.foregroundView && self.foregroundView.tag == 1002){
KWMPageControl *pageControl = (KWMPageControl *)self.foregroundView;
pageControl.currentPage = self.pageIndex;
}
if(self.delegate){
if([self.delegate respondsToSelector:@selector(bannerView:onPageIndexChange:)]){
[self.delegate bannerView:self onPageIndexChange:self.pageIndex];
}
if([self.delegate respondsToSelector:@selector(bannerView:backgroundView:updateBackgroundViewAtIndex:)]
&& self.backgroundView){
[self.delegate bannerView:self backgroundView:self.backgroundView updateBackgroundViewAtIndex:self.pageIndex];
}
if([self.delegate respondsToSelector:@selector(bannerView:foregroundView:updateForegroundViewAtIndex:)]
&& self.foregroundView){
[self.delegate bannerView:self foregroundView:self.backgroundView updateForegroundViewAtIndex:self.pageIndex];
}
}
}
#pragma mark iCarousel methods
- (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
if(self.delegate){
return [self.delegate numberOfPagesForBanner:self];
}
return 0;
}
- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel
{
return 3;
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view{
if(self.delegate){
return [self.delegate bannerView:self reusingView:view pageAtIndex:index];
}
return nil;
}
-(void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index{
if(self.delegate){
[self.delegate bannerView:self onClickPage:index];
}
}
- (void)carouselDidEndDragging:(iCarousel *)carousel willDecelerate:(BOOL)decelerate{
[self updateUIOnPageChange];
}
- (void)carouselDidEndDecelerating:(iCarousel *)carousel{
[self updateUIOnPageChange];
}
- (CGFloat)carouselItemWidth:(iCarousel *)carousel
{
return self.frame.size.width;
}
-(void)carouselDidEndScrollingAnimation:(iCarousel *)carousel{
isScroll = NO;
}
-(void)carouselDidScroll:(iCarousel *)carousel{
isScroll = YES;
}
- (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
switch (option)
{
case iCarouselOptionWrap:
{
return YES;
}
default:
{
return value;
}
}
}
@end
......@@ -104,6 +104,9 @@
#define BigImage 3
//collection all的id
#define Collection_All_ID 191372166
//默认欧元汇率,如果安装后第一次请求最新汇率数据失败,会使用该汇率显示价格
//#define ExchangeRate 7.6625
//#define ExchangeRateString @"7.6625"
......
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