Commit 097973b0 authored by Sandy's avatar Sandy

商品管理、多选等界面

parent 6c487b97
This diff is collapsed.
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "blueCycle.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "blueCycle@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "commodityManagementImage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "commodityManagementImage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "searchIcon.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "searchIcon@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
}, },
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "bac@2x.png",
"scale" : "2x" "scale" : "2x"
}, },
{ {
......
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Earphones-microphone.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Earphones-microphone@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "commodityDetailBack.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "commodityDetailBack@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "commodityDetailHome.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "commodityDetailHome@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "commodityShop.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "commodityShop@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "shareCommodity.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "shareCommodity@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "blackbtn.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "blackbtn@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "greenbtn_bg.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "greenbtn_bg@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "mutipleDeselect.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "mutipleDeselect@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "mutipleselect.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "mutipleselect@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
//
// CommodityDetailBottomView.h
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CommodityDetailBottomView : UIView
@end
//
// CommodityDetailBottomView.m
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityDetailBottomView.h"
@interface CommodityDetailBottomView ()
@property (weak, nonatomic) IBOutlet UIButton *buttonPhone;
@property (weak, nonatomic) IBOutlet UIButton *buttonShop;
@property (weak, nonatomic) IBOutlet UIButton *buttonShare;
@end
@implementation CommodityDetailBottomView
- (void)awakeFromNib {
// Initialization code
self.buttonPhone.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.buttonShop.imageView.contentMode = UIViewContentModeScaleAspectFit;
[self.buttonShare.imageView.image stretchableImageWithLeftCapWidth:10 topCapHeight:10];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
//
// CommodityDetailTopView.h
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void (^topBlock)(void);
@interface CommodityDetailTopView : UIView
@property (nonatomic, copy) topBlock bacBlock;
@property (nonatomic, copy) topBlock homeBlock;
@end
//
// CommodityDetailTopView.m
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityDetailTopView.h"
@implementation CommodityDetailTopView
- (IBAction)backActiion:(UIButton *)sender {
self.bacBlock();
}
- (IBAction)homeAction:(id)sender {
self.homeBlock();
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CommodityDetailTopView"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="CommodityDetailTopView">
<rect key="frame" x="0.0" y="0.0" width="320" height="86"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Tkk-cJ-NcJ">
<rect key="frame" x="16" y="36" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="KLK-dL-PO5"/>
<constraint firstAttribute="height" constant="44" id="xgs-oj-Y1x"/>
</constraints>
<state key="normal" image="commodityDetailBack"/>
<connections>
<action selector="backActiion:" destination="-1" eventType="touchUpInside" id="Rcx-bi-ED3"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gWc-ej-xNw">
<rect key="frame" x="260" y="36" width="44" height="44"/>
<state key="normal" image="commodityDetailHome"/>
<connections>
<action selector="homeAction:" destination="-1" eventType="touchUpInside" id="2HN-As-jcv"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="Tkk-cJ-NcJ" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="16" id="JmR-0w-Qyc"/>
<constraint firstItem="gWc-ej-xNw" firstAttribute="width" secondItem="Tkk-cJ-NcJ" secondAttribute="width" id="PBJ-rl-Icr"/>
<constraint firstItem="gWc-ej-xNw" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="36" id="TMk-Uk-QD4"/>
<constraint firstItem="Tkk-cJ-NcJ" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="36" id="YBT-NF-xA7"/>
<constraint firstItem="gWc-ej-xNw" firstAttribute="height" secondItem="Tkk-cJ-NcJ" secondAttribute="height" id="eYt-HG-UEE"/>
<constraint firstAttribute="trailing" secondItem="gWc-ej-xNw" secondAttribute="trailing" constant="16" id="wvz-3B-6lR"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="318" y="89"/>
</view>
</objects>
<resources>
<image name="commodityDetailBack" width="68" height="68"/>
<image name="commodityDetailHome" width="70" height="68"/>
</resources>
</document>
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "SortView.h" #import "SortView.h"
#import "CoverShadowView.h" #import "CoverShadowView.h"
#import "IBTUIViewController.h"
@interface SortView ()<UITableViewDataSource, UITableViewDelegate> @interface SortView ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, assign) CGFloat clickCount; @property (nonatomic, assign) CGFloat clickCount;
@property (nonatomic, strong) CoverShadowView *coverView; @property (nonatomic, strong) CoverShadowView *coverView;
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *arrTitles; @property (nonatomic, strong) NSArray *arrTitles;
@property (nonatomic, strong) NSMutableArray *arrSelectedMark; @property (nonatomic, strong) NSMutableArray *arrSelectedMark;
@property (nonatomic, assign) BOOL isTableOpen;
@end @end
@implementation SortView @implementation SortView
...@@ -61,8 +63,10 @@ ...@@ -61,8 +63,10 @@
- (void)rightBtnAction { - (void)rightBtnAction {
[self.rightBtn setTitleColor:kCustomGreenColor forState:UIControlStateNormal]; [self.rightBtn setTitleColor:kCustomGreenColor forState:UIControlStateNormal];
[self.leftBtn setTitleColor:kTextColorBlack forState:UIControlStateNormal]; [self.leftBtn setTitleColor:kTextColorBlack forState:UIControlStateNormal];
[self iconAnimate]; if (self.isTableOpen == YES) {
[self hideTableView]; [self iconAnimate];
[self hideTableView];
}
} }
- (CoverShadowView *)coverView { - (CoverShadowView *)coverView {
...@@ -75,36 +79,52 @@ ...@@ -75,36 +79,52 @@
}; };
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.bottom + 64, ScreenSize.width, 0) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self; }
self.arrTitles = @[@"综合排序",@"新品排序",@"收藏排序",@"价格从低到高",@"价格从高到低",@"佣金从低到高",@"佣金从高到低"]; return _coverView;
self.arrSelectedMark = [NSMutableArray array]; }
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.bottom + 64, ScreenSize.width, 0) style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_arrTitles = @[@"综合排序",@"新品排序",@"收藏排序",@"价格从低到高",@"价格从高到低",@"佣金从低到高",@"佣金从高到低"];
_arrSelectedMark = [NSMutableArray array];
for (int i = 0; i < self.arrTitles.count; i++) { for (int i = 0; i < self.arrTitles.count; i++) {
[self.arrSelectedMark addObject:@"NO"]; [self.arrSelectedMark addObject:@"NO"];
} }
[self.arrSelectedMark replaceObjectAtIndex:0 withObject:@"YES"]; [_arrSelectedMark replaceObjectAtIndex:0 withObject:@"YES"];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier"]; [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier"];
[self.window addSubview:self.tableView]; [self.window addSubview:_tableView];
[self showTableView]; [self showTableView];
} }
return _coverView; return _tableView;
} }
#pragma mark ==============animate============== #pragma mark ==============animate==============
- (void)showTableView { - (void)showTableView {
WS(weakSelf) [self.coverView show];
//self.leftSortAction(YES);
[self viewController].navigationItem.leftBarButtonItem.enabled = NO;
WS(weakSelf)
self.isTableOpen = YES;
[UIView animateWithDuration:0.3 delay:0 options:(UIViewAnimationOptionCurveEaseIn) animations:^{ [UIView animateWithDuration:0.3 delay:0 options:(UIViewAnimationOptionCurveEaseIn) animations:^{
weakSelf.tableView.height = 44 * weakSelf.arrTitles.count; weakSelf.tableView.height = 44 * weakSelf.arrTitles.count;
} completion:nil]; } completion:nil];
} }
- (void)hideTableView { - (void)hideTableView {
[self.coverView hide];
// self.leftSortAction(NO);
[self viewController].navigationItem.leftBarButtonItem.enabled = YES;
self.isTableOpen = NO;
WS(weakSelf) WS(weakSelf)
[UIView animateWithDuration:0.3 animations:^{ [UIView animateWithDuration:0.3 animations:^{
weakSelf.tableView.height = 0; weakSelf.tableView.height = 0;
...@@ -160,7 +180,7 @@ ...@@ -160,7 +180,7 @@
} }
- (void)setLeftBtnTitle:(NSString *)str { - (void)setLeftBtnTitle:(NSString *)str {
[self.leftBtn setTitle:[NSString stringWithFormat:@"%@ ",str] forState:UIControlStateNormal]; [self.leftBtn setTitle:[NSString stringWithFormat:@"%@ ",str] forState:UIControlStateNormal];//只是为了让标题位置正确
if (str.length > 4) { if (str.length > 4) {
self.leftBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 130, 0, 0); self.leftBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 130, 0, 0);
self.leftBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0); self.leftBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
...@@ -172,13 +192,11 @@ ...@@ -172,13 +192,11 @@
- (void)leftAction:(UIButton *)btn { - (void)leftAction:(UIButton *)btn {
if (self.clickCount != M_PI) { if (self.clickCount != M_PI) {
[self.coverView show];
[self showTableView]; [self showTableView];
self.leftSortAction(YES);
}else{ }else{
[self.coverView hide];
[self hideTableView]; [self hideTableView];
self.leftSortAction(NO);
} }
[self iconAnimate]; [self iconAnimate];
} }
...@@ -195,6 +213,17 @@ ...@@ -195,6 +213,17 @@
}]; }];
} }
- (UIViewController *)viewController
{
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[IBTUIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
/* /*
// Only override drawRect: if you perform custom drawing. // Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation. // An empty implementation adversely affects performance during animation.
......
//
// CommodityManagementSortView.h
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void (^sortBlock)(BOOL);
typedef void (^selectedRow)(NSInteger);
@interface CommodityManagementSortView : UIView
@property (nonatomic, copy) sortBlock leftSortAction;
@property (nonatomic, copy) sortBlock rightAction;
@property (nonatomic, copy) selectedRow rightTableSelect;
@property (nonatomic, copy) selectedRow leftTableSelect;
- (instancetype)sortView;
@end
//
// CommodityManagementSortView.m
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityManagementSortView.h"
#import "CoverShadowView.h"
#import "IBTUIViewController.h"
@interface CommodityManagementSortView ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, assign) CGFloat clickCount;
@property (nonatomic, assign) CGFloat rightClickCount;
@property (nonatomic, strong) CoverShadowView *coverView;
@property (nonatomic, strong) UIButton *leftBtn;
@property (nonatomic, strong) UIButton *rightBtn;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *arrTitles;
@property (nonatomic, strong) NSArray *arrLeft;
@property (nonatomic, strong) NSArray *arrRight;
@property (nonatomic, assign) NSInteger selectedMark;
@property (nonatomic, assign) BOOL isTableOpen;
@end
@implementation CommodityManagementSortView
- (instancetype)sortView {
self.arrLeft = @[@"销售中",@"未上架"];
self.arrRight = @[@"最新排序",@"销量排序",@"佣金排序",@"售价排序"];
UIView *grayLine = [UIView new];
[self addSubview:grayLine];
grayLine.sd_layout.topSpaceToView(self, 5).bottomSpaceToView(self, 5).centerXEqualToView(self).centerYEqualToView(self).widthIs(1);
grayLine.backgroundColor = kBacroundColor;
self.backgroundColor = kSysWhite;
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self addSubview:leftButton];
self.leftBtn = leftButton;
[leftButton setTitle:@"销售中 " forState:UIControlStateNormal];
[leftButton setTitleColor:kTextColorBlack forState:UIControlStateNormal];
[leftButton setImage:[UIImage imageNamed:@"downIcon"] forState:UIControlStateNormal];
[leftButton addTarget:self action:@selector(leftAction:) forControlEvents:UIControlEventTouchUpInside];
leftButton.imageView.tintColor = kTextColorGray;
leftButton.imageEdgeInsets = UIEdgeInsetsMake(0, 115, 0, 0);
leftButton.sd_layout.topEqualToView(self).leftEqualToView(self).rightSpaceToView(grayLine,0).bottomEqualToView(self);
[leftButton updateLayout];
self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[self addSubview:self.rightBtn];
[self.rightBtn setTitle:@"最新排序 " forState:UIControlStateNormal];
[self.rightBtn setTitleColor:kTextColorBlack forState:UIControlStateNormal];
[self.rightBtn setImage:[UIImage imageNamed:@"downIcon"] forState:UIControlStateNormal];
self.rightBtn.imageView.tintColor = kTextColorGray;
self.rightBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 115, 0, 0); self.rightBtn.sd_layout.leftSpaceToView(grayLine,0).topEqualToView(self).bottomEqualToView(self).rightEqualToView(self);
[self.rightBtn addTarget:self action:@selector(rightBtnAction) forControlEvents:UIControlEventTouchUpInside];
UIView *viewGrayBottom = [UIView new];
viewGrayBottom.backgroundColor = kCutLineColorLiteGray;
[self addSubview:viewGrayBottom];
viewGrayBottom.sd_layout.bottomEqualToView(self).leftEqualToView(self).rightEqualToView(self).heightIs(1);
return self;
}
- (CoverShadowView *)coverView {
if (!_coverView) {
_coverView = [[CoverShadowView alloc] initWithSpaceToTop:self.bottom + 64];
[self.window addSubview:_coverView];
WS(weakSelf)
_coverView.tapAction = ^{
if (weakSelf.arrTitles == weakSelf.arrLeft) {
[weakSelf leftAction:nil];
}else{
[weakSelf rightBtnAction];
}
};
}
return _coverView;
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.bottom + 64, ScreenSize.width, 0) style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier"];
[self.window addSubview:_tableView];
[self showTableView];
}
return _tableView;
}
#pragma mark ==============animate==============
- (void)showTableView {
[self.coverView show];
//self.leftSortAction(YES);
[self viewController].navigationItem.leftBarButtonItem.enabled = NO;
WS(weakSelf)
self.isTableOpen = YES;
[UIView animateWithDuration:0.3 delay:0 options:(UIViewAnimationOptionCurveEaseIn) animations:^{
weakSelf.tableView.height = 44 * weakSelf.arrTitles.count;
[weakSelf.tableView reloadData];
} completion:nil];
}
- (void)hideTableView {
[self.coverView hide];
// self.leftSortAction(NO);
[self viewController].navigationItem.leftBarButtonItem.enabled = YES;
self.isTableOpen = NO;
WS(weakSelf)
[UIView animateWithDuration:0.3 animations:^{
weakSelf.tableView.height = 0;
}];
}
#pragma mark ==============table delegate==============
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
return self.arrTitles.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
self.selectedMark = indexPath.row;
[tableView reloadData];
NSString *space;
if (self.arrTitles == self.arrLeft) {
space = @"left";
[self leftAction:nil];
[self setLeftBtnTitle:self.arrTitles[indexPath.row]];
[self.leftBtn setTitleColor:kCustomGreenColor forState:UIControlStateNormal];
[self.rightBtn setTitleColor:kTextColorBlack forState:UIControlStateNormal];
self.leftTableSelect(indexPath.row);
}else{
space = @"right";
[self rightBtnAction];
[self.rightBtn setTitle:[NSString stringWithFormat:@"%@ ",self.arrTitles[indexPath.row]] forState:UIControlStateNormal];
[self.leftBtn setTitleColor:kTextColorBlack forState:UIControlStateNormal];
[self.rightBtn setTitleColor:kCustomGreenColor forState:UIControlStateNormal];
self.rightTableSelect(indexPath.row);
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
cell.textLabel.text = self.arrTitles[indexPath.row];
// Configure the cell...
cell.tintColor = kCustomGreenColor;
if (self.selectedMark == indexPath.row) {
cell.textLabel.textColor = kCustomGreenColor;
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}else{
cell.textLabel.textColor = [UIColor blackColor];
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
return cell;
}
- (void)setLeftBtnTitle:(NSString *)str {
[self.leftBtn setTitle:[NSString stringWithFormat:@"%@ ",str] forState:UIControlStateNormal];//只是为了让标题位置正确
if (str.length > 4) {
self.leftBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 130, 0, 0);
self.leftBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
}else{
self.leftBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 115, 0, 0);
self.leftBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
}
}
- (void)leftAction:(UIButton *)btn {
_arrTitles = _arrLeft;
if (self.clickCount != M_PI) {
[self showTableView];
}else{
[self hideTableView];
}
[self iconAnimate];
}
- (void)rightBtnAction {
_arrTitles = _arrRight;
if (self.rightClickCount != M_PI) {
[self showTableView];
}else{
[self hideTableView];
}
[self rightIconAnimate];
}
#pragma mark =========== animate ===========
//控制左边的按钮上的剪头动画
- (void)iconAnimate {
self.clickCount = self.clickCount + M_PI;
if (self.clickCount > M_PI * 2 ) {
self.clickCount = M_PI;
}
WS(weakSelf)
[UIView animateWithDuration:0.3 animations:^{
weakSelf.leftBtn.imageView.transform = CGAffineTransformMakeRotation(weakSelf.clickCount);
}];
}
- (void)rightIconAnimate {
self.rightClickCount = self.rightClickCount + M_PI;
if (self.rightClickCount > M_PI * 2 ) {
self.rightClickCount = M_PI;
}
WS(weakSelf)
[UIView animateWithDuration:0.3 animations:^{
weakSelf.rightBtn.imageView.transform = CGAffineTransformMakeRotation(weakSelf.rightClickCount);
}];
}
- (UIViewController *)viewController
{
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[IBTUIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
//
// CommodityManagementTopView.h
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CommodityManagementTopView : UIView
@end
//
// CommodityManagementTopView.m
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityManagementTopView.h"
#import "UIView+Category.h"
#import "ManagementViewController.h"
@interface CommodityManagementTopView ()
@property (weak, nonatomic) IBOutlet UIButton *buttonAdd;
@property (weak, nonatomic) IBOutlet UIButton *buttonManagement;
@end
@implementation CommodityManagementTopView
- (void)awakeFromNib {
self.buttonAdd.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.buttonManagement.imageView.contentMode = UIViewContentModeScaleAspectFit;
}
- (IBAction)managementAct:(id)sender {
ManagementViewController *manageVC = [[ManagementViewController alloc] init];
[[self viewController] PushViewController:manageVC animated:YES];
CLog(@"m");
}
- (IBAction)addAct:(id)sender {
CLog(@"a");
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CommodityManagementTopView"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="CommodityManagementTopView">
<rect key="frame" x="0.0" y="0.0" width="320" height="130"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="y9I-zx-duH">
<rect key="frame" x="0.0" y="10" width="160" height="110"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<state key="normal" title="添加商品" image="blueCycle">
<color key="titleColor" red="0.066666666669999999" green="0.066666666669999999" blue="0.066666666669999999" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="addAct:" destination="-1" eventType="touchUpInside" id="aJF-tW-db7"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uY6-mf-dlQ">
<rect key="frame" x="160" y="10" width="160" height="110"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<state key="normal" title="商品管理" image="blueCycle">
<color key="titleColor" red="0.066666666669999999" green="0.066666666669999999" blue="0.066666666669999999" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="managementAct:" destination="iN0-l3-epB" eventType="touchUpInside" id="PVf-zg-LlH"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="uY6-mf-dlQ" secondAttribute="bottom" constant="10" id="NFT-Vw-BB0"/>
<constraint firstAttribute="bottom" secondItem="y9I-zx-duH" secondAttribute="bottom" constant="10" id="PlI-tf-fbr"/>
<constraint firstItem="y9I-zx-duH" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="Qw1-7E-jh4"/>
<constraint firstItem="uY6-mf-dlQ" firstAttribute="leading" secondItem="y9I-zx-duH" secondAttribute="trailing" id="YHT-vo-xLb"/>
<constraint firstItem="y9I-zx-duH" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="eCz-HR-9PT"/>
<constraint firstItem="uY6-mf-dlQ" firstAttribute="leading" secondItem="y9I-zx-duH" secondAttribute="trailing" id="ez9-x3-7VG"/>
<constraint firstItem="y9I-zx-duH" firstAttribute="width" secondItem="uY6-mf-dlQ" secondAttribute="width" id="laQ-PI-72r"/>
<constraint firstAttribute="trailing" secondItem="uY6-mf-dlQ" secondAttribute="trailing" id="pMe-Wv-efg"/>
<constraint firstItem="uY6-mf-dlQ" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="uzO-wC-Mlp"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="buttonAdd" destination="y9I-zx-duH" id="l6u-3V-Nwc"/>
<outlet property="buttonManagement" destination="uY6-mf-dlQ" id="Msy-US-Iyp"/>
</connections>
<point key="canvasLocation" x="300" y="-26"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="ubP-w9-KTu">
<rect key="frame" x="0.0" y="0.0" width="46" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<point key="canvasLocation" x="368" y="158"/>
</button>
</objects>
<resources>
<image name="blueCycle" width="62" height="62"/>
</resources>
</document>
//
// CommodityMutipleSelectBottomView.h
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CommodityMutipleSelectBottomView : UIView
@property (weak, nonatomic) IBOutlet UIButton *buttonSelectAll;
@property (weak, nonatomic) IBOutlet UIButton *buttonDelete;
@property (weak, nonatomic) IBOutlet UIButton *buttonPutOnShelf;
@property (weak, nonatomic) IBOutlet UIButton *buttonPutOffShelf;
- (void)selectAll;
- (void)deselectAll;
@end
//
// CommodityMutipleSelectBottomView.m
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityMutipleSelectBottomView.h"
@interface CommodityMutipleSelectBottomView ()
@end
@implementation CommodityMutipleSelectBottomView
- (void)selectAll {
[self.buttonSelectAll setImage:[UIImage imageNamed:@"mutipleselect"] forState:UIControlStateNormal];
}
- (void)deselectAll {
[self.buttonSelectAll setImage:[UIImage imageNamed:@"mutipleDeselect"] forState:UIControlStateNormal];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
This diff is collapsed.
//
// CommodityTableViewCell.h
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CommodityTableViewCell : UITableViewCell
@end
//
// CommodityTableViewCell.m
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityTableViewCell.h"
@implementation CommodityTableViewCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="130" id="KGk-i7-Jjw" customClass="CommodityTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="130"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="129"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="commodityManagementImage" translatesAutoresizingMaskIntoConstraints="NO" id="f2b-xv-2mY">
<rect key="frame" x="16" y="13" width="90" height="103"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="1q5-Yj-TUg"/>
<constraint firstAttribute="height" constant="81" id="diJ-tJ-yal"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="diJ-tJ-yal"/>
</mask>
</variation>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Bloem天然草本更年期综合营养 胶囊100粒 " textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sKb-Ty-VZw">
<rect key="frame" x="114" y="13" width="192" height="41"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥279" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="exC-Ji-hHu">
<rect key="frame" x="114" y="69" width="52" height="23"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<color key="textColor" red="1" green="0.3921568627" blue="0.3921568627" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="佣金:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ovJ-rr-g9w">
<rect key="frame" x="174" y="69" width="57" height="23"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¥9.8" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eSJ-Pe-NgQ">
<rect key="frame" x="231" y="69" width="50" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="销量:19" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WH8-2u-i8A">
<rect key="frame" x="114" y="95" width="69" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="eSJ-Pe-NgQ" firstAttribute="leading" secondItem="ovJ-rr-g9w" secondAttribute="trailing" id="1Eu-FE-9iO"/>
<constraint firstItem="WH8-2u-i8A" firstAttribute="bottom" secondItem="f2b-xv-2mY" secondAttribute="bottom" id="2jl-ph-Q74"/>
<constraint firstItem="exC-Ji-hHu" firstAttribute="leading" secondItem="sKb-Ty-VZw" secondAttribute="leading" id="2ym-N5-akU"/>
<constraint firstAttribute="trailingMargin" secondItem="sKb-Ty-VZw" secondAttribute="trailing" constant="6" id="B7G-hY-Wof"/>
<constraint firstItem="ovJ-rr-g9w" firstAttribute="top" secondItem="sKb-Ty-VZw" secondAttribute="bottom" constant="8" id="Os9-8x-QDz"/>
<constraint firstItem="ovJ-rr-g9w" firstAttribute="top" secondItem="exC-Ji-hHu" secondAttribute="top" id="Qpw-J3-B4x"/>
<constraint firstItem="sKb-Ty-VZw" firstAttribute="top" secondItem="f2b-xv-2mY" secondAttribute="top" id="UZc-es-AXD"/>
<constraint firstItem="WH8-2u-i8A" firstAttribute="leading" secondItem="exC-Ji-hHu" secondAttribute="leading" id="UrY-Fj-Ae6"/>
<constraint firstItem="f2b-xv-2mY" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="8" id="Vsv-Em-BKg"/>
<constraint firstItem="sKb-Ty-VZw" firstAttribute="leading" secondItem="f2b-xv-2mY" secondAttribute="trailing" constant="8" id="Wqn-cW-aBf"/>
<constraint firstItem="eSJ-Pe-NgQ" firstAttribute="centerY" secondItem="ovJ-rr-g9w" secondAttribute="centerY" id="nao-gR-Wpb"/>
<constraint firstItem="ovJ-rr-g9w" firstAttribute="centerY" secondItem="exC-Ji-hHu" secondAttribute="centerY" id="qH9-2w-Aye"/>
<constraint firstItem="WH8-2u-i8A" firstAttribute="top" secondItem="exC-Ji-hHu" secondAttribute="bottom" constant="3" id="rLS-bt-cyL"/>
<constraint firstAttribute="bottomMargin" secondItem="f2b-xv-2mY" secondAttribute="bottom" constant="5" id="t7F-mG-u1e"/>
<constraint firstItem="f2b-xv-2mY" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="5" id="uEu-KH-AMz"/>
<constraint firstItem="ovJ-rr-g9w" firstAttribute="leading" secondItem="exC-Ji-hHu" secondAttribute="trailing" constant="8" id="vjl-Db-Hu7"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="Os9-8x-QDz"/>
<exclude reference="Qpw-J3-B4x"/>
</mask>
</variation>
</tableViewCellContentView>
<color key="tintColor" red="0.48627450980392156" green="0.76470588235294112" blue="0.14509803921568626" alpha="1" colorSpace="calibratedRGB"/>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<point key="canvasLocation" x="274" y="244"/>
</tableViewCell>
</objects>
<resources>
<image name="commodityManagementImage" width="185" height="185"/>
</resources>
</document>
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
//隐藏navigationbar
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO]; [self.navigationController setNavigationBarHidden:NO];
......
//
// CommodityDetailViewController.h
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "IBTUIViewController.h"
@interface CommodityDetailViewController : IBTUIViewController
@end
//
// CommodityDetailViewController.m
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityDetailViewController.h"
#import "CommodityDetailBottomView.h"
#import "CommodityDetailTopView.h"
#import "CommodityMutipleSelectBottomView.h"
@interface CommodityDetailViewController ()
@property (nonatomic, strong) CommodityDetailBottomView *bottomView;
@property (nonatomic, strong) CommodityDetailTopView *topView;
@end
@implementation CommodityDetailViewController
- (void)viewDidLoad {
[super viewDidLoad];
if ([[[UIDevice currentDevice] systemVersion] doubleValue] > 7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
self.view.backgroundColor = kBacroundColor;
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight - 67)];
NSURL *url = [NSURL URLWithString:@"https://m.jd.com"];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
[self.view addSubview:webView];
webView.userInteractionEnabled = YES;
[self.view addSubview:self.topView];
WS(weakSelf)
self.topView.bacBlock = ^{
[weakSelf.navigationController popViewControllerAnimated:YES];
};
_topView.homeBlock = ^{
CLog(@"home");
};
[self.view addSubview:self.bottomView];
// Do any additional setup after loading the view.
}
//隐藏navigationbar
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES];
}
#pragma mark =========== lazy loading ===========
- (CommodityDetailBottomView *)bottomView {
if (!_bottomView) {
_bottomView = [CommodityDetailBottomView viewWithNibName:@"CommodityDetailBottomView"];
_bottomView.frame = CGRectMake(0, kHeight - 67, kWidth, 67);
}
return _bottomView;
}
- (CommodityDetailTopView *)topView {
if (!_topView) {
_topView = [CommodityDetailTopView viewWithNibName:@"CommodityDetailTopView"];
_topView.frame = CGRectMake(0, 0, kWidth, 86);
}
return _topView;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "CommodityListViewController.h" #import "CommodityListViewController.h"
#import "CommodityListCollectionViewCell.h" #import "CommodityListCollectionViewCell.h"
#import "SortView.h" #import "SortView.h"
#import "CommodityDetailViewController.h"
#define kCellID @"commodityCell" #define kCellID @"commodityCell"
@interface CommodityListViewController ()<UICollectionViewDataSource, UICollectionViewDelegate> @interface CommodityListViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) UICollectionView *collectionView;
...@@ -26,10 +27,9 @@ ...@@ -26,10 +27,9 @@
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
- (void)viewWillDisappear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
[super viewWillDisappear:animated]; [super viewWillAppear:animated];
//CLog(@"%@",NSStringFromCGRect(_sortView.frame)); [self.navigationController setNavigationBarHidden:NO];
} }
- (void)setUpSortView { - (void)setUpSortView {
...@@ -39,14 +39,6 @@ ...@@ -39,14 +39,6 @@
_sortView.backgroundColor = [UIColor whiteColor]; _sortView.backgroundColor = [UIColor whiteColor];
//根据是否点开排序列表,控制返回按钮是否可以点击
WS(weakSelf)
_sortView.leftSortAction = ^(BOOL isOpen){
//CLog(@"%d",isOpen);
weakSelf.navigationItem.leftBarButtonItem.enabled = !isOpen;
};
//点击排序列表之后回调传入选中行数 //点击排序列表之后回调传入选中行数
_sortView.selecedBlock = ^(NSInteger row){ _sortView.selecedBlock = ^(NSInteger row){
CLog(@"%ld", (long)row); CLog(@"%ld", (long)row);
...@@ -75,8 +67,15 @@ ...@@ -75,8 +67,15 @@
return 20; return 20;
} }
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
CommodityDetailViewController *detailVC = [[CommodityDetailViewController alloc] init];
[self.navigationController pushViewController:detailVC animated:YES];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CommodityListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath]; CommodityListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
//假数据
NSArray *arr = @[@"234",@"23",@"234234",@"2344",@"33",@"2",@"234",@"23",@"234234",@"2344",@"33",@"2",@"234",@"23",@"234234",@"2344",@"33",@"2",@"234",@"23",@"234234",@"2344",@"33",@"2"]; NSArray *arr = @[@"234",@"23",@"234234",@"2344",@"33",@"2",@"234",@"23",@"234234",@"2344",@"33",@"2",@"234",@"23",@"234234",@"2344",@"33",@"2",@"234",@"23",@"234234",@"2344",@"33",@"2"];
cell.labelSalePrice.text = arr[indexPath.row]; cell.labelSalePrice.text = arr[indexPath.row];
return cell; return cell;
......
//
// CommodityManagementViewController.h
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "IBTUIViewController.h"
@interface CommodityManagementViewController : IBTUIViewController
@end
//
// CommodityManagementViewController.m
// ALand
//
// Created by Z on 16/3/28.
// Copyright © 2016年 Z. All rights reserved.
//
#import "CommodityManagementViewController.h"
#import "CommodityManagementTopView.h"
#import "CommodityManagementSortView.h"
#import "UITableView+Category.h"
#import "CommodityTableViewCell.h"
#define kCellId @"CommodityTableViewCell.h"
@interface CommodityManagementViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) CommodityManagementTopView *topView;
@property (nonatomic, strong) CommodityManagementSortView *sorView;
@property (nonatomic, strong) UITableView *tableView;
@end
@implementation CommodityManagementViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"商品管理";
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"searchIcon"] style:UIBarButtonItemStyleDone target:self action:@selector(searchAct)];
rightBtn.tintColor = kTextColorDarkGray;
self.navigationItem.rightBarButtonItem = rightBtn;
[self.view addSubview:self.topView];
[self.view addSubview:self.sorView];
self.sorView.leftTableSelect = ^(NSInteger row){
CLog(@"l");
};
self.sorView.rightTableSelect = ^(NSInteger row){
CLog(@"r");
};
//
_tableView = [UITableView plainTableViewWithTarget:self cellNibName:@"CommodityTableViewCell" cellId:kCellId];
[self.view addSubview:_tableView];
_tableView.sd_layout.topSpaceToView(self.sorView,0).leftEqualToView(self.view).rightEqualToView(self.view).bottomEqualToView(self.view);
// Do any additional setup after loading the view.
}
#pragma mark =========== action ===========
- (void)searchAct {
CLog(@"search");
}
#pragma mark =========== tableview delegate ===========
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CommodityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId forIndexPath:indexPath];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 130;
}
#pragma mark =========== lazy loading ===========
- (CommodityManagementSortView *)sorView {
if (!_sorView) {
_sorView = [[CommodityManagementSortView new] sortView];
_sorView.frame = CGRectMake(0, _topView.bottom - 50, kWidth, 49);
}
return _sorView;
}
- (CommodityManagementTopView *)topView {
if (!_topView) {
_topView = [CommodityManagementTopView viewWithNibName:@"CommodityManagementTopView"];
_topView.frame = CGRectMake(0, 0, kWidth, 64 + 64);
}
return _topView;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
...@@ -11,9 +11,12 @@ ...@@ -11,9 +11,12 @@
#import "HomeCollectionViewCell.h" #import "HomeCollectionViewCell.h"
#import "CommodityListViewController.h" #import "CommodityListViewController.h"
#import "AddCommodityViewController.h" #import "AddCommodityViewController.h"
#import "SDCycleScrollView.h"
#import "CommodityManagementViewController.h"
#define kHomeCollectionViewID @"HomeCollectionViewID" #define kHomeCollectionViewID @"HomeCollectionViewID"
#define kCollectionViewHeadHeight 350 #define kCollectionViewHeadHeight 350
#import "SDCycleScrollView.h"
@interface HomeCollectionViewController ()<UICollectionViewDataSource, UICollectionViewDelegate,SDCycleScrollViewDelegate> @interface HomeCollectionViewController ()<UICollectionViewDataSource, UICollectionViewDelegate,SDCycleScrollViewDelegate>
@property (nonatomic, strong) NSArray *cellTitle; @property (nonatomic, strong) NSArray *cellTitle;
@property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) UICollectionView *collectionView;
...@@ -110,7 +113,42 @@ ...@@ -110,7 +113,42 @@
return cell; return cell;
} }
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
case 0:
{
CommodityManagementViewController *managementVC = [[CommodityManagementViewController alloc] init];
managementVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:managementVC animated:YES];
}
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
default:
break;
}
}
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
......
//
// ManagementViewController.h
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import "IBTUIViewController.h"
@interface ManagementViewController : IBTUIViewController
@end
//
// ManagementViewController.m
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import "ManagementViewController.h"
#import "CommodityManagementSortView.h"
#import "CommodityTableViewCell.h"
#import "UITableView+Category.h"
#import "CommodityMutipleSelectBottomView.h"
#define kCellId @"CommodityTableViewCell.h"
@interface ManagementViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) CommodityManagementSortView *sorView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) CommodityMutipleSelectBottomView *bottomView;
@end
@implementation ManagementViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"批量管理";
[self.view addSubview:self.sorView];
self.sorView.leftTableSelect = ^(NSInteger row){
CLog(@"l");
};
self.sorView.rightTableSelect = ^(NSInteger row){
CLog(@"r");
};
_tableView = [UITableView plainTableViewWithTarget:self cellNibName:@"CommodityTableViewCell" cellId:kCellId];
[self.view addSubview:_tableView];
_tableView.sd_layout.topSpaceToView(self.sorView,0).leftEqualToView(self.view).rightEqualToView(self.view).bottomSpaceToView(self.view, 70);
_tableView.editing = YES;
_tableView.allowsMultipleSelectionDuringEditing = YES;
_bottomView = [CommodityMutipleSelectBottomView viewWithNibName:@"CommodityMutipleSelectBottomView"];
_bottomView.frame = CGRectMake(0, kHeight - 64 - 70, kWidth, 70 + 64);
[self.view addSubview:_bottomView];
[_bottomView.buttonSelectAll addTarget:self action:@selector(selectAll:) forControlEvents:UIControlEventTouchUpInside];
// Do any additional setup after loading the view.
}
#pragma mark =========== action ===========
- (void)selectAll:(UIButton *)btn {//tag 等于1表示全选
if (btn.tag == 0) {
[self.bottomView selectAll];
for (int i = 0; i < 10; i ++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];
}
btn.tag = 1;
}else{
[self.bottomView deselectAll];
for (int i = 0; i < 10; i ++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
btn.tag = 0;
}
}
#pragma mark =========== tableview delegate ===========
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
}
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CommodityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId forIndexPath:indexPath];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 130;
}
#pragma mark =========== lazyloading ===========
- (CommodityManagementSortView *)sorView {
if (!_sorView) {
_sorView = [[CommodityManagementSortView new] sortView];
_sorView.frame = CGRectMake(0, 0, kWidth, 49);
}
return _sorView;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tdr-oJ-D2D"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tdr-oJ-D2D">
<rect key="frame" x="0.0" y="0.0" width="375" height="502"/> <rect key="frame" x="0.0" y="0.0" width="375" height="502"/>
<subviews> <subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="login_top" translatesAutoresizingMaskIntoConstraints="NO" id="gIO-Jz-jhA"> <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="login_top" translatesAutoresizingMaskIntoConstraints="NO" id="gIO-Jz-jhA">
<rect key="frame" x="71" y="94" width="234" height="136"/> <rect key="frame" x="71" y="94" width="234" height="136"/>
</imageView> </imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Drd-sW-LYv"> <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Drd-sW-LYv">
<rect key="frame" x="32" y="274" width="311" height="44"/> <rect key="frame" x="32" y="274" width="311" height="44"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="300" id="1bQ-Cb-7AQ"/> <constraint firstAttribute="width" constant="300" id="1bQ-Cb-7AQ"/>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<action selector="rigistAction:" destination="-1" eventType="touchUpInside" id="Qaf-df-5Yo"/> <action selector="rigistAction:" destination="-1" eventType="touchUpInside" id="Qaf-df-5Yo"/>
</connections> </connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Te4-Rx-W0K"> <button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Te4-Rx-W0K">
<rect key="frame" x="32" y="348" width="311" height="44"/> <rect key="frame" x="32" y="348" width="311" height="44"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="300" id="do6-tj-oIb"/> <constraint firstAttribute="width" constant="300" id="do6-tj-oIb"/>
......
//
// UITableView+Category.h
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UITableView (Category)
+ (UITableView *)plainTableViewWithTarget:(id)target cellNibName:(NSString *)nibName cellId:(NSString *)cellId;
@end
//
// UITableView+Category.m
// ALand
//
// Created by Z on 16/3/29.
// Copyright © 2016年 Z. All rights reserved.
//
#import "UITableView+Category.h"
@implementation UITableView (Category)
+ (UITableView *)plainTableViewWithTarget:(id)target cellNibName:(NSString *)nibName cellId:(NSString *)cellId {
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
tableView.dataSource = target;
tableView.delegate = target;
[tableView registerNib:[UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]] forCellReuseIdentifier:cellId];
return tableView;
}
@end
...@@ -9,6 +9,18 @@ ...@@ -9,6 +9,18 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface UIView (Category) @interface UIView (Category)
/**
* 根据nib名字获取view
*
* @param viewName
*
* @return
*/
+ (id)viewWithNibName:(NSString *)viewName; + (id)viewWithNibName:(NSString *)viewName;
/**
* 获取view的控制器
*
* @return 控制器
*/
- (UIViewController *)viewController;
@end @end
...@@ -16,4 +16,15 @@ ...@@ -16,4 +16,15 @@
NSArray* nibView = [[NSBundle mainBundle] loadNibNamed:viewName owner:nil options:nil]; NSArray* nibView = [[NSBundle mainBundle] loadNibNamed:viewName owner:nil options:nil];
return [nibView objectAtIndex:0]; return [nibView objectAtIndex:0];
} }
- (UIViewController *)viewController
{
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[IBTUIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
@end @end
...@@ -18,11 +18,12 @@ ...@@ -18,11 +18,12 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = kBacroundColor;
self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"fafafa"]; self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"fafafa"];
UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bac"] style:UIBarButtonItemStyleDone target:self action:@selector(popAction)]; UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bac"] style:UIBarButtonItemStyleDone target:self action:@selector(popAction)];
leftBtn.tintColor = [UIColor colorWithHexString:@"aeaeae"]; leftBtn.tintColor = kTextColorDarkGray;
self.navigationItem.leftBarButtonItem = leftBtn; self.navigationItem.leftBarButtonItem = leftBtn;
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:21],NSFontAttributeName, [UIColor colorWithHexString:@"333333"], NSForegroundColorAttributeName,nil]]; [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:24],NSFontAttributeName, [UIColor colorWithHexString:@"333333"], NSForegroundColorAttributeName,nil]];
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
......
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