Commit 31fd98d7 authored by 谢卓城's avatar 谢卓城

finish home

parents
Pipeline #58 failed with stages
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
*.xcworkspace
!default.xcworkspace
# OS X
.DS_Store
#CocoaPods
Pods
*.xcuserdatad
*.xcscmblueprint
*.xcworkspace
xcuserdata/
UserInterfaceState.xcuserstate
project.xcworkspace/
UserInterface.xcuserstate
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BAC30D8C25340BA9007757AB"
BuildableName = "Mall-iOS.app"
BlueprintName = "Mall-iOS"
ReferencedContainer = "container:Mall-iOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BAC30D8C25340BA9007757AB"
BuildableName = "Mall-iOS.app"
BlueprintName = "Mall-iOS"
ReferencedContainer = "container:Mall-iOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BAC30D8C25340BA9007757AB"
BuildableName = "Mall-iOS.app"
BlueprintName = "Mall-iOS"
ReferencedContainer = "container:Mall-iOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
//
// AppDelegate.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
//
// AppDelegate.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "AppDelegate.h"
#import "HomeViewController.h"
#import "ShoppingCartViewController.h"
#import "MacroDefinition.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UITabBarController *tab = [[UITabBarController alloc] init];
HomeViewController *home = [[HomeViewController alloc] init];
home.title = @"主页";
home.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"主页"
image:[UIImage imageNamed:@"index"]
selectedImage:[UIImage imageNamed:@"index_s"]];
UINavigationController* homeNav = [[UINavigationController alloc] initWithRootViewController:home];
ShoppingCartViewController *shopping = [[ShoppingCartViewController alloc] init];
shopping.title = @"购物车";
shopping.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"购物车"
image:[UIImage imageNamed:@"shoppingCart"]
selectedImage:[UIImage imageNamed:@"shoppingCart_s"]];
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:163.0f/255.0f green:46.0f/255.0f blue:46.0f/255.0f alpha:1.0f]];
UINavigationController* shoppingNav = [[UINavigationController alloc] initWithRootViewController:shopping];
tab.viewControllers = @[homeNav,shoppingNav];
tab.selectedIndex = 1;
self.window.rootViewController = tab;
[self.window makeKeyAndVisible];
return YES;
}
#pragma mark - UISceneSession lifecycle
/**
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
*/
@end
//
// SceneDelegate.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate>
@property (strong, nonatomic) UIWindow * window;
@end
//
// SceneDelegate.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "SceneDelegate.h"
#import "HomeViewController.h"
#import "ShoppingCartViewController.h"
#import "MacroDefinition.h"
@interface SceneDelegate ()
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
UIWindowScene *windowScene = (UIWindowScene *)scene;
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
self.window.frame = windowScene.coordinateSpace.bounds;
UITabBarController *tab = [[UITabBarController alloc] init];
HomeViewController *home = [[HomeViewController alloc] init];
home.title = @"主页";
home.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"主页"
image:[UIImage imageNamed:@"index"]
selectedImage:[UIImage imageNamed:@"index_s"]];
UINavigationController* homeNav = [[UINavigationController alloc] initWithRootViewController:home];
ShoppingCartViewController *shopping = [[ShoppingCartViewController alloc] init];
shopping.title = @"购物车";
shopping.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"购物车"
image:[UIImage imageNamed:@"shoppingCart"]
selectedImage:[UIImage imageNamed:@"shoppingCart_s"]];
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:163.0f/255.0f green:46.0f/255.0f blue:46.0f/255.0f alpha:1.0f]];
UINavigationController* shoppingNav = [[UINavigationController alloc] initWithRootViewController:shopping];
tab.viewControllers = @[homeNav,shoppingNav];
/**
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:163.0f/255.0f green:46.0f/255.0f blue:46.0f/255.0f alpha:1.0f]];
if (@available(iOS 11.0, *)){
[UITableView appearance].contentInsetAdjustmentBehavior= UIScrollViewContentInsetAdjustmentNever;
[UITableView appearance].estimatedRowHeight = 0;
[UITableView appearance].estimatedSectionHeaderHeight = 0;
[UITableView appearance].estimatedSectionFooterHeight = 0;
}else {
self.window.rootViewController.automaticallyAdjustsScrollViewInsets = NO;
}
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UIButton appearance] setExclusiveTouch:YES];
*/
self.window.rootViewController = tab;
[self.window makeKeyAndVisible];
}
- (void)sceneDidDisconnect:(UIScene *)scene {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}
- (void)sceneDidBecomeActive:(UIScene *)scene {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
- (void)sceneWillResignActive:(UIScene *)scene {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
- (void)sceneWillEnterForeground:(UIScene *)scene {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
- (void)sceneDidEnterBackground:(UIScene *)scene {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
@end
//
// ShoppingCartViewController.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ShoppingCartViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// ShoppingCartViewController.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "ShoppingCartViewController.h"
@interface ShoppingCartViewController ()
@end
@implementation ShoppingCartViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setUp];
}
-(void)setUp {
self.view.backgroundColor = [UIColor whiteColor];
}
@end
//
// ActivityCollectionCell.h
// Mall-iOS
//
// Created by Nemo on 2020/10/13.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ActivityCollectionCell : UICollectionViewCell
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *detailText;
@property (nonatomic, copy) NSString *url;
@end
NS_ASSUME_NONNULL_END
//
// ActivityCollectionCell.m
// Mall-iOS
//
// Created by Nemo on 2020/10/13.
//
#import "ActivityCollectionCell.h"
#import <Masonry.h>
#import "MacroDefinition.h"
@interface ActivityCollectionCell()
@property (nonatomic, strong) UIImageView *iconIv;
@property (nonatomic, strong) UILabel *detailTextLb;
@property (nonatomic, strong) UILabel *titleLb;
@end
@implementation ActivityCollectionCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
self.backgroundColor = RGBCOLOR(247, 247, 247);
[self.contentView addSubview:self.iconIv];
[self.iconIv mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.contentView addSubview:self.titleLb];
[self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.inset(15);
make.right.lessThanOrEqualTo(self.mas_right).inset(15);
}];
[self.contentView addSubview:self.detailTextLb];
[self.detailTextLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.titleLb);
make.top.equalTo(self.titleLb.mas_bottom).offset(5);
}];
}
- (void)setTitle:(NSString *)title {
_title = title;
self.detailTextLb.text = title;
}
- (void)setDetailText:(NSString *)detailText {
_detailText = detailText;
self.detailTextLb.text = detailText;
}
- (void)setUrl:(NSString *)url {
_url = url;
self.iconIv.image = [UIImage imageNamed:@"group_portrait"];
}
- (UILabel *)detailTextLb {
if (_detailTextLb == nil) {
_detailTextLb = [[UILabel alloc] init];
_detailTextLb.font = FONTSIZE(13);
_detailTextLb.textColor = RGBCOLOR(102, 102, 102);
_detailTextLb.text = @"热销爆款不容错过";
}
return _detailTextLb;;
}
- (UILabel *)titleLb {
if (_titleLb == nil) {
_titleLb = [[UILabel alloc] init];
_titleLb.font = FONTSIZE(13);
_titleLb.textColor = RGBCOLOR(33, 33, 33);
_titleLb.text = @"新品热销榜";
}
return _titleLb;;
}
- (UIImageView *)iconIv {
if (_iconIv == nil) {
_iconIv = [[UIImageView alloc] init];
_iconIv.image = [UIImage imageNamed:@"group_portrait"];
}
return _iconIv;
}
@end
//
// HomeClassficationCell.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface HomeClassficationCell : UICollectionViewCell
@property (nonatomic, strong) NSString *iconName;
@property (nonatomic, strong) NSString *iconUrl;
@end
NS_ASSUME_NONNULL_END
//
// HomeClassficationCell.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "HomeClassficationCell.h"
#import "MacroDefinition.h"
#import <Masonry.h>
@interface HomeClassficationCell()
@property (nonatomic, strong) UIImageView *iconIv;
@property (nonatomic, strong) UILabel *nameLb;
@end
@implementation HomeClassficationCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
self.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:self.iconIv];
[self.iconIv mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(45);
make.top.left.equalTo(self);
}];
[self.contentView addSubview:self.nameLb];
[self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.centerX.equalTo(self);
}];
}
- (void)setIconName:(NSString *)iconName {
_iconName = iconName;
self.nameLb.text = iconName;
}
- (void)setIconUrl:(NSString *)iconUrl {
_iconUrl = iconUrl;
self.iconIv.image = [UIImage imageNamed:@"group_portrait"];
}
- (UILabel *)nameLb {
if (_nameLb == nil) {
_nameLb = [[UILabel alloc] init];
_nameLb.font = FONTSIZE(13);
_nameLb.textColor = RGBCOLOR(102, 102, 102);
}
return _nameLb;;
}
- (UIImageView *)iconIv {
if (_iconIv == nil) {
_iconIv = [[UIImageView alloc] init];
_iconIv.image = [UIImage imageNamed:@"group_portrait"];
}
return _iconIv;
}
@end
//
// HomeGoodsCell.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class HomeGoodsModel;
@interface HomeGoodsCell : UICollectionViewCell
@property (nonatomic, strong) HomeGoodsModel *model;
@end
NS_ASSUME_NONNULL_END
//
// HomeGoodsCell.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "HomeGoodsCell.h"
#import <Masonry.h>
#import "MacroDefinition.h"
#import "AttributLabel.h"
#import "HomeGoodsModel.h"
@interface HomeGoodsCell()
@property (nonatomic, strong) AttributLabel *goodsTextLb;
@property (nonatomic, strong) AttributLabel *goodsPriceLb;
@property (nonatomic, strong) UIImageView *goodsIv;
@end
@implementation HomeGoodsCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
self.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:self.goodsIv];
[self.goodsIv mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.right.left.inset(15);
make.width.equalTo(self.goodsIv.mas_height).multipliedBy(1);
}];
[self.contentView addSubview:self.goodsTextLb];
[self.goodsTextLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.goodsIv.mas_bottom).offset(12);
make.left.right.equalTo(self.goodsIv);
make.width.equalTo(self.goodsIv.mas_height).multipliedBy(1);
}];
[self.contentView addSubview:self.goodsPriceLb];
[self.goodsPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.goodsTextLb.mas_bottom).offset(7);
make.left.equalTo(self.goodsTextLb);
make.width.lessThanOrEqualTo(self.goodsIv.mas_width);
}];
}
-(void)setModel:(HomeGoodsModel *)model {
_model = model;
if (model.goodsType == HomeGoodsModelTypeNone) {
_goodsPriceLb.text = [NSString stringWithFormat:@"¥%.f",model.price];
_goodsTextLb.text = model.goodsTitle;
}else {
NSString *text = [NSString stringWithFormat:@"¥%.f ¥%.f",model.price,model.originPrice];
[_goodsPriceLb setStrikethroughForString:text strikethroughText:[NSString stringWithFormat:@"¥%.f",model.originPrice] strikethroughColor:RGBCOLOR(191, 191, 191)];
[_goodsTextLb setIconForString:model.goodsTitle image:[UIImage imageNamed:@"group_portrait"]];
}
}
- (UIImageView *)goodsIv {
if (_goodsIv == nil) {
_goodsIv = [[UIImageView alloc] init];
_goodsIv.image = [UIImage imageNamed:@"group_portrait"];
}
return _goodsIv;
}
- (AttributLabel *)goodsPriceLb {
if (_goodsPriceLb == nil) {
_goodsPriceLb = [[AttributLabel alloc] init];
_goodsPriceLb.font = FONTSIZE(14);
_goodsPriceLb.textColor = RGBCOLOR(102, 102, 102);
[_goodsPriceLb setStrikethroughForString:@"¥169 ¥249" strikethroughText:@"¥249" strikethroughColor:RGBCOLOR(191, 191, 191)];
}
return _goodsPriceLb;
}
- (AttributLabel *)goodsTextLb {
if (_goodsTextLb == nil) {
_goodsTextLb = [[AttributLabel alloc] init];
_goodsTextLb.font = FONTSIZE(13);
_goodsTextLb.textColor = RGBCOLOR(102, 102, 102);
_goodsTextLb.numberOfLines = 2;
[_goodsTextLb setIconForString:@" 琴岛智能除螨电热毯\n安全定时 智能控温" image:[UIImage imageNamed:@"group_portrait"]];
}
return _goodsTextLb;
}
@end
//
// HomeGoodsModel.h
// Mall-iOS
//
// Created by Nemo on 2020/10/13.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
HomeGoodsModelTypeNone,
HomeGoodsModelTypeCom,
} HomeGoodsModelType;
@interface HomeGoodsModel : NSObject
@property (nonatomic, copy) NSString *goodsUrl;
@property (nonatomic, copy) NSString *goodsTitle;
@property (nonatomic, assign) CGFloat price;
@property (nonatomic, assign) CGFloat originPrice;
@property (nonatomic, assign) HomeGoodsModelType goodsType;
@end
NS_ASSUME_NONNULL_END
//
// HomeGoodsModel.m
// Mall-iOS
//
// Created by Nemo on 2020/10/13.
//
#import "HomeGoodsModel.h"
@implementation HomeGoodsModel
@end
//
// ActivityView.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ActivityView : UIView
@property (nonatomic, strong) NSArray *dataSource;
@end
NS_ASSUME_NONNULL_END
//
// ActivityView.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "ActivityView.h"
#import "UICollectionViewCell+Extension.h"
#import "ActivityCollectionCell.h"
#import <Masonry.h>
#import <QMUIKit.h>
@interface ActivityView()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collectionView;
@end
@implementation ActivityView
- (instancetype)init
{
self = [super init];
if (self) {
[self setupUI];
}
return self;
}
-(void)setupUI {
self.backgroundColor = [UIColor whiteColor];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 4;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
ActivityCollectionCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:[ActivityCollectionCell identifier] forIndexPath:indexPath];
return cell;
}
-(UICollectionView *)collectionView {
if (_collectionView == nil) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
CGFloat width = (SCREEN_WIDTH -15)/2.0;
// 上下的距离
layout.minimumLineSpacing = 5;
layout.minimumInteritemSpacing = 5;
CGFloat height = 135.0/180.0*width;
layout.itemSize = CGSizeMake(width, height);
layout.sectionInset = UIEdgeInsetsMake(0, 5, 0, 0);
_collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.showsHorizontalScrollIndicator = NO;
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.backgroundColor = [UIColor whiteColor];
[self addSubview:_collectionView];
[ActivityCollectionCell registerClassForCollectionView:_collectionView];
}
return _collectionView;
}
@end
//
// HomeClassificationView.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class HomeClassificationModel;
@interface HomeClassificationView : UIView
/// 数据源
@property (nonatomic, strong) NSArray <HomeClassificationModel *>*dataSource;
@end
@interface HomeClassificationModel : NSObject
/// icon Url
@property (nonatomic, copy) NSString *iconUrl;
/// icon name
@property (nonatomic, copy) NSString *iconName;
@end
NS_ASSUME_NONNULL_END
//
// HomeClassificationView.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "HomeClassificationView.h"
#import <QMUIKit.h>
#import "HomeClassficationCell.h"
#import "UICollectionViewCell+Extension.h"
#import <Masonry.h>
@interface HomeClassificationView()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collectionView;
@end
@implementation HomeClassificationView
- (instancetype)init
{
self = [super init];
if (self) {
[self setupUI];
}
return self;
}
-(void)setupUI {
self.backgroundColor = [UIColor whiteColor];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
}
- (void)setDataSource:(NSArray<HomeClassificationModel *> *)dataSource {
_dataSource = dataSource;
[self.collectionView reloadData];
}
#pragma --mark delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.dataSource.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
HomeClassficationCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:[HomeClassficationCell identifier] forIndexPath:indexPath];
HomeClassificationModel *model = self.dataSource[indexPath.row];
cell.iconName = model.iconName;
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
HomeClassificationModel *model = self.dataSource[indexPath.row];
[QMUITips showSucceed:model.iconName inView:QMUIHelper.visibleViewController.view hideAfterDelay:2];
}
-(UICollectionView *)collectionView {
if (_collectionView == nil) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
CGFloat lineSpacing = (SCREEN_WIDTH -45*5)/6.0;
// 上下的距离
layout.minimumLineSpacing = lineSpacing;
layout.minimumInteritemSpacing = 20;
//CGFloat height = 255/188*width;
layout.itemSize = CGSizeMake(45, 72);
layout.sectionInset = UIEdgeInsetsMake(30, lineSpacing, 30, 0);
_collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.decelerationRate = 0.8;
_collectionView.showsHorizontalScrollIndicator = NO;
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.backgroundColor = [UIColor whiteColor];
[self addSubview:_collectionView];
[HomeClassficationCell registerClassForCollectionView:_collectionView];
}
return _collectionView;
}
@end
@implementation HomeClassificationModel
@end
//
// HomeCollectionHeaderView.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface HomeCollectionHeaderView : UICollectionReusableView
@property (nonatomic, strong) NSDictionary *headerDict;
@end
NS_ASSUME_NONNULL_END
//
// HomeCollectionHeaderView.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "HomeCollectionHeaderView.h"
#import <Masonry.h>
#import "MacroDefinition.h"
#import <SDCycleScrollView.h>
#import "UIImage+Extension.h"
#import "HomeClassificationView.h"
#import "ActivityView.h"
#import <SDWebImage.h>
#import <QMUIKit.h>
@interface HomeCollectionHeaderView()<SDCycleScrollViewDelegate>
@property (nonatomic, strong) UIButton *searchBtn;
@property (nonatomic, strong) SDCycleScrollView *cycleView;
@property (nonatomic, strong) HomeClassificationView *homeClassficationView;
@property (nonatomic, strong) UIImageView *recommendIv;
@property (nonatomic, strong) ActivityView *activityView;
@end
@implementation HomeCollectionHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
self.backgroundColor = [UIColor whiteColor];
[self addSubview:self.searchBtn];
[_searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self).inset(12);
make.top.mas_offset(8);
make.height.mas_equalTo(27);
}];
NSURL *url = [NSURL URLWithString:@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3584899235,2312422629&fm=26&gp=0.jpg"];
self.cycleView.imageURLStringsGroup = @[url,url,url];
self.homeClassficationView.dataSource = @[];
[self.recommendIv sd_setImageWithURL:[NSURL URLWithString:@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3584899235,2312422629&fm=26&gp=0.jpg"]];
self.activityView.dataSource = @[];
UILabel *titleLb = [[UILabel alloc] init];
titleLb.font = FONTBOLDSIZE(15);
titleLb.text = @"每日精选";
[self addSubview:titleLb];
[titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.inset(19);
make.bottom.inset(13);
}];
CALayer *splitLine = [CALayer layer];
splitLine.frame = CGRectMake(0, self.bounds.size.height-45, self.bounds.size.width, 5);
splitLine.backgroundColor = RGBCOLOR(242, 245, 247).CGColor;
[self.layer addSublayer:splitLine];
CALayer *bottomLine = [CALayer layer];
bottomLine.backgroundColor = RGBCOLOR(242, 245, 247).CGColor;
bottomLine.frame = CGRectMake(0, self.bounds.size.height-1, self.bounds.size.width, 1);
[self.layer addSublayer:bottomLine];
}
- (void)setHeaderDict:(NSDictionary *)headerDict {
_headerDict = headerDict;
NSArray *ary = @[@"居家",@"鞋包配饰",@"服装",
@"电器",@"婴童",@"饮食",
@"特色区",@"洗护",@"餐厨",@"文体"];
@autoreleasepool {
NSMutableArray <HomeClassificationModel *>*list = [[NSMutableArray alloc] init];
for (int i = 0; i < ary.count; i ++) {
HomeClassificationModel *model = [[HomeClassificationModel alloc] init];
model.iconUrl = @"";
model.iconName = ary[i];
[list addObject:model];
}
self.homeClassficationView.dataSource = list;
}
}
-(void)searchAction {
NSLog(@"======test");
[QMUITips showSucceed:@"搜索被点击!" inView:kAppWindow() hideAfterDelay:2];
}
- (UIImageView *)recommendIv {
if (_recommendIv == nil) {
_recommendIv = [[UIImageView alloc] init];
[self addSubview:_recommendIv];
CGFloat height = 100.0/360.0*SCREEN_WIDTH;
[_recommendIv mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(height);
make.top.equalTo(self.homeClassficationView.mas_bottom);
make.right.left.equalTo(self).inset(8);
}];
}
return _recommendIv;
}
- (ActivityView *)activityView {
if (_activityView == nil) {
_activityView = [[ActivityView alloc] init];
[self addSubview:_activityView];
CGFloat width = (SCREEN_WIDTH-15)/2.0;
CGFloat height = 135.0/180.0*width;
[_activityView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(height*2+5);
make.top.equalTo(self.recommendIv.mas_bottom).inset(27);
make.right.left.equalTo(self);
}];
}
return _activityView;
}
-(HomeClassificationView *)homeClassficationView {
if (_homeClassficationView == nil) {
_homeClassficationView = [[HomeClassificationView alloc] init];
[self addSubview:_homeClassficationView];
CGFloat height = 231.0/375.0*SCREEN_WIDTH;
[_homeClassficationView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(height);
make.top.equalTo(self.cycleView.mas_bottom);
make.right.left.equalTo(self.cycleView);
}];
}
return _homeClassficationView;
}
- (SDCycleScrollView *)cycleView {
if (_cycleView == nil) {
CGFloat height = 170.0/SCREEN_WIDTH*375.0;
_cycleView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 43, SCREEN_WIDTH, height) delegate:self placeholderImage:[UIImage imageWithColor:[UIColor grayColor]]];
_cycleView.backgroundColor = [UIColor whiteColor];
[self addSubview:_cycleView];
}
return _cycleView;
}
-(UIButton *)searchBtn {
if (_searchBtn == nil) {
_searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_searchBtn setImage:[UIImage imageNamed:@"search"] forState:UIControlStateNormal];
[_searchBtn setImage:[UIImage imageNamed:@"search"] forState:UIControlStateHighlighted];
[_searchBtn setBackgroundColor:RGBCOLOR(243, 243, 243)];
_searchBtn.titleLabel.font = FONTSIZE(12);
[_searchBtn setTitle:@" 搜索商品,发现好物" forState:UIControlStateNormal];
[_searchBtn setTitle:@" 搜索商品,发现好物" forState:UIControlStateHighlighted];
[_searchBtn setTitleColor:RGBCOLOR(191, 191, 191) forState:UIControlStateNormal];
[_searchBtn addTarget:self action:@selector(searchAction) forControlEvents:UIControlEventTouchUpInside];
_searchBtn.layer.cornerRadius = 13;
_searchBtn.layer.masksToBounds = YES;
}
return _searchBtn;;
}
@end
//
// HomeViewController.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface HomeViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// HomeViewController.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "HomeViewController.h"
#import <Masonry.h>
#import <QMUIKit.h>
#import <MJRefresh.h>
#import "HomeCollectionHeaderView.h"
#import "UICollectionViewCell+Extension.h"
#import "UICollectionReusableView+Extension.h"
#import "HomeGoodsCell.h"
#import "MacroDefinition.h"
#import "HomeGoodsModel.h"
@interface HomeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, assign) CGFloat collectionViewHeaderHeight;
@property (nonatomic, strong) NSMutableArray *dataSource;
@end
@implementation HomeViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setUp];
[self requestNewData];
}
- (void)requestNewData {
if (self.dataSource.count > 0) {
[self.dataSource removeAllObjects];
}
for (int i = 0 ; i < 10; i ++) {
HomeGoodsModel *model = [[HomeGoodsModel alloc] init];
model.goodsTitle = @"琴岛智能除螨电热毯\n安全定时 智能控温";
model.price = 169.0f + i;
model.originPrice = 249.0 + i;
model.goodsType = (i%2)?HomeGoodsModelTypeNone:HomeGoodsModelTypeCom;
[self.dataSource addObject:model];
}
[self.collectionView reloadData];
[self.collectionView.mj_header endRefreshing];
}
- (void)requestMoreData {
for (int i = 0 ; i < 10; i ++) {
HomeGoodsModel *model = [[HomeGoodsModel alloc] init];
model.goodsTitle = @"琴岛智能除螨电热毯\n安全定时 智能控温";
model.price = 169.0f + i;
model.originPrice = 249.0 + i;
model.goodsType = (i%2)?HomeGoodsModelTypeNone:HomeGoodsModelTypeCom;
[self.dataSource addObject:model];
}
[self.collectionView reloadData];
[self.collectionView.mj_footer endRefreshing];
}
- (void)setUp {
self.collectionViewHeaderHeight = 926.0/375*SCREEN_WIDTH;
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.collectionView];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
_dataSource = [[NSMutableArray alloc] init];
WeakSelf
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
[weakSelf requestMoreData];
}];
footer.automaticallyChangeAlpha = YES;
self.collectionView.mj_footer = footer;
self.collectionView.mj_header = [MJRefreshStateHeader headerWithRefreshingBlock:^{
[weakSelf requestNewData];
}];
}
- (void)searchAction {
}
#pragma mark - UICollectionViewDelegate
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
if ([kind isEqualToString:UICollectionElementKindSectionHeader]){
HomeCollectionHeaderView *header = [HomeCollectionHeaderView dequeueReusableSupplementaryHeaderViewOfKind:collectionView index:indexPath];
header.headerDict = @{};
return header;
}
return [UICollectionReusableView new];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.dataSource.count;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
return CGSizeMake(SCREEN_WIDTH, self.collectionViewHeaderHeight);
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
HomeGoodsCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:[HomeGoodsCell identifier] forIndexPath:indexPath];
cell.model = self.dataSource[indexPath.row];
return cell;
}
-(UICollectionView *)collectionView {
if (_collectionView == nil) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
layout.minimumLineSpacing = 1;
layout.minimumInteritemSpacing = 0;
CGFloat width = (SCREEN_WIDTH -1)/2;
CGFloat height = 255.0/188.0*width;
layout.itemSize = CGSizeMake(width, height);
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
_collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.decelerationRate = 0.8;
_collectionView.showsHorizontalScrollIndicator = NO;
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.backgroundColor = RGBCOLOR(238, 238, 238);
[self.view addSubview:_collectionView];
[HomeGoodsCell registerClassForCollectionView:_collectionView];
[HomeCollectionHeaderView registerClassHeaderForCollectionView:_collectionView];
}
return _collectionView;
}
@end
//
// MacroDefinition.h
// CQ_App
//
// Created by mac on 2019/3/20.
// Copyright © 2019年 mac. All rights reserved.
//
#ifndef MacroDefinition_h
#define MacroDefinition_h
#pragma mark ****** 宏方法 ******
//iOS 11.0 配置
#define AdjustsScrollViewInsetNever(controller,view) if(@available(iOS 11.0, *)) {view.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;} else if([controller isKindOfClass:[UIViewController class]]) {controller.automaticallyAdjustsScrollViewInsets = false;}
#define kStatusBarAndNavigationBarHeight (nScreenHeight() >= 812.0 ? 88.f : 64.f)
#define kSafeAreaBottomHeight (nScreenHeight() >= 812.0 ? 34.0f : 0.0)
#define kTabbarHeight (nScreenHeight() >= 812.0 ? 83.f : 49.f)
//数据验证
#define StrValid(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""])
#define SafeStr(f) (StrValid(f) ? f:@"")
#define HasString(str,key) ([str rangeOfString:key].location!=NSNotFound)
#define ValidStr(f) StrValid(f)
#define ValidDict(f) (f!=nil && [f isKindOfClass:[NSDictionary class]] && [f count]>0)
#define ValidArray(f) (f!=nil && [f isKindOfClass:[NSArray class]] && [f count]>0)
#define ValidNum(f) (f!=nil && [f isKindOfClass:[NSNumber class]])
#define ValidClass(f,cls) (f!=nil && [f isKindOfClass:[cls class]])
#define ValidData(f) (f!=nil && [f isKindOfClass:[NSData class]])
//单例化一个类
#define SINGLETON_FOR_HEADER(className) \
\
+ (className *)shared##className;
#define SINGLETON_FOR_CLASS(className) \
static className *shared##className = nil;\
+(instancetype)allocWithZone:(struct _NSZone *)zone\
{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
if (shared##className == nil) {\
shared##className = [super allocWithZone:zone];\
}\
});\
return shared##className;\
}\
+(instancetype)shared##className\
{\
return [[self alloc] init];\
}\
-(id)copyWithZone:(NSZone *)zone\
{\
return shared##className;\
}\
-(id)mutableCopyWithZone:(NSZone *)zone\
{\
return shared##className;\
}
#pragma mark ————— 获取系统对象内联方法 —————
CG_INLINE UIWindow *kGetLastWindow() {
UIWindow *lastWindow = [UIApplication sharedApplication].keyWindow;
if (!lastWindow) {
lastWindow = [UIApplication sharedApplication].windows.lastObject;
}
return lastWindow;
}
CG_INLINE UIApplication *kApplication() {
return [UIApplication sharedApplication];
}
CG_INLINE UIView *kAppWindow() {
return [UIApplication sharedApplication].delegate.window;
}
CG_INLINE UIViewController *kRootViewController() {
return [UIApplication sharedApplication].delegate.window.rootViewController;
}
/**
CG_INLINE CGFloat nScreenWidth() {
return SCREEN_WIDTH;
}
CG_INLINE CGFloat nScreenHeight() {
return YYScreenSize().height;
}
*/
CG_INLINE CGFloat kSafeAreaTopHeight() {
return [[UIApplication sharedApplication] statusBarFrame].size.height;
}
/**
CG_INLINE CGFloat tabBarHeight() {
return 40+(nScreenHeight() >= 812.0 ? 34.0f : 5.0);
}
CG_INLINE CGFloat kKeyboardHeight() {
if(nScreenHeight() == 812 && nScreenWidth() == 375){
return 291.f;
}else if(nScreenHeight() == 736 && nScreenWidth() == 414){
return 216.f;
}else if(nScreenHeight() == 667 && nScreenWidth() == 375){
return 216.f;
}else if(nScreenHeight() == 568 && nScreenWidth() == 320){
return 253.f;
}else{
return 216.f;
}
}
*/
#pragma mark - ——————— 字体内联方法 ————————
CG_INLINE UIFont *FONTSIZE(CGFloat a) {
return [UIFont fontWithName:@"PingFangSC-Regular" size:a];
}
CG_INLINE UIFont *FONTBOLDSIZE(CGFloat a) {
return [UIFont fontWithName:@"PingFangSC-Semibold" size:a];
}
#pragma mark ————— UICOLOR内联方法 —————
/**
* 输入RGBA值获取颜色
*
* @param r RED值
* @param g GREEN值
* @param b BLUE值
* @param a 透明度
*
* @return UIColor
*/
CG_INLINE UIColor * RGBACOLOR(CGFloat r,CGFloat g,CGFloat b,CGFloat a) {
return [UIColor colorWithRed:(r) / 255.0f green:(g) / 255.0f blue:(b) / 255.0f alpha:(a)];
}
/**
输入RGB值获取颜色
@param r RED值
@param g GREEN值
@param b BLUE值
@return UIColor
*/
CG_INLINE UIColor * RGBCOLOR(CGFloat r,CGFloat g,CGFloat b) {
return [UIColor colorWithRed:(r) / 255.0f green:(g) / 255.0f blue:(b) / 255.0f alpha:1];
}
/**
* 输入16进制值获取颜色
*
* @param rgbValue 16进制值
*
* @return UIColor
*/
CG_INLINE UIColor * HEXCOLOR(NSUInteger rgbValue) {
return [UIColor colorWithRed:(((float)((rgbValue & 0xFF0000) >> 16))) / 255.0f green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0f blue:((float)(rgbValue & 0xFF)) / 255.0f alpha:1];
}
/**
随机颜色
@return 随机颜色
*/
CG_INLINE UIColor * RandomColor() {
return [UIColor colorWithRed:arc4random_uniform(256) / 255.0f green:arc4random_uniform(256) / 255.0f blue:arc4random_uniform(256) / 255.0f alpha:1];
}
#pragma mark ————— 通知中心 —————
/**
通知中心
@return NSNotificationCenter
*/
CG_INLINE NSNotificationCenter * KNOTE() {
return [NSNotificationCenter defaultCenter];
}
/**
通知中心发送通知
@param name 通知名称
@param obj 通知参数
*/
CG_INLINE void KNOTEPost(NSString *name,id obj) {
[[NSNotificationCenter defaultCenter] postNotificationName:name object:obj];
}
/**
通知中心发送通知
@param name 通知名称
@param obj 通知参数
@param userInfo 传递参数
*/
CG_INLINE void KNOTEPostUserInfo(NSString *name,id obj, NSDictionary *userInfo) {
[[NSNotificationCenter defaultCenter] postNotificationName:name object:obj userInfo:userInfo];
}
/**
移除通知监听
@param name 通知名称
*/
CG_INLINE void KNOTERemoveObserver(NSString *name,id _self) {
[[NSNotificationCenter defaultCenter] removeObserver:_self name:name object:nil];
}
/**
添加通知观察者
@param observer 观察对象
@param selector 相应事件
@param name 通知名称
*/
CG_INLINE void KNOTEAddObserver(NSString *name,NSString *selector,id observer) {
[[NSNotificationCenter defaultCenter] addObserver:observer selector:@selector(selector) name:name object:nil];
}
#pragma mark ————— 偏好设置UserDefault —————
/**
用户设置偏好设置
@param keyName 偏好名称
@param object 值
*/
CG_INLINE void UserDefaults_Set_WithKey(NSString *keyName,id object) {
[[NSUserDefaults standardUserDefaults] setObject:object forKey:keyName];
[[NSUserDefaults standardUserDefaults] synchronize];
}
/**
用户设置偏好获取
@param keyName 偏好名称
*/
CG_INLINE id UserDefaults_Get_WithKey(NSString *keyName) {
return [[NSUserDefaults standardUserDefaults] objectForKey:keyName];
}
/**
用户设置偏好删除
@param keyName 偏好名称
*/
CG_INLINE void UserDefaults_Del_WithKey(NSString *keyName) {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:keyName];
[[NSUserDefaults standardUserDefaults] synchronize];
}
#pragma mark ————— 多线程内联函数 —————
//GCD - 一次性执行
CG_INLINE void kDISPATCH_ONCE_BLOCK(dispatch_block_t onceBlock) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, onceBlock);
}
//GCD - 在Main线程上运行
CG_INLINE void kDISPATCH_MAIN_THREAD(dispatch_block_t block) {
dispatch_async(dispatch_get_main_queue(), block);
}
//GCD - 开启异步线程
CG_INLINE void kDISPATCH_GLOBAL_QUEUE_DEFAULT(dispatch_block_t block) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
}
//GCD - 延时
CG_INLINE void kDISPATCH_AFTER(CGFloat seconds,dispatch_block_t block) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(seconds * NSEC_PER_SEC)), dispatch_get_main_queue(), block);
}
//基础数据转字符串
CG_INLINE NSString *IntegerString(NSInteger integer) {
return [NSString stringWithFormat:@"%li",integer];
}
//CGFloat转字符串
CG_INLINE NSString *FloatString(CGFloat f) {
return [NSString stringWithFormat:@"%.f",f];
}
//弱引用
#define WeakSelf __weak typeof(self) weakSelf = self;
#define StrongSelf __strong typeof(weakSelf) strongSelf = weakSelf;
#ifdef DEBUG
#define NSLog(format, ...) printf("[%s] %s [第%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else
#define NSLog(format, ...)
#endif
#endif /* MacroDefinition_h */
//
// UICollectionReusableView+Extension.h
// xiangwan
//
// Created by mac on 2019/8/27.
// Copyright © 2019 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UICollectionReusableView (Extension)
/// Footer Class注册方法
+ (void)registerClassFooterForCollectionView:(UICollectionView *)collectionView;
/// Header Class注册方法
+ (void)registerClassHeaderForCollectionView:(UICollectionView *)collectionView;
/// Footer Nib注册方法
+ (void)registerNibFooterForCollectionView:(UICollectionView *)collectionView;
/// Header Nib注册方法
+ (void)registerNibHeaderForCollectionView:(UICollectionView *)collectionView;
+(instancetype)dequeueReusableSupplementaryHeaderViewOfKind:(UICollectionView *)collectionView index:(NSIndexPath *)indexPath;
+(instancetype)dequeueReusableSupplementaryFooterViewOfKind:(UICollectionView *)collectionView index:(NSIndexPath *)indexPath;
@end
NS_ASSUME_NONNULL_END
//
// UICollectionReusableView+Extension.m
// xiangwan
//
// Created by mac on 2019/8/27.
// Copyright © 2019 mac. All rights reserved.
//
#import "UICollectionReusableView+Extension.h"
@implementation UICollectionReusableView (Extension)
+ (void)registerClassFooterForCollectionView:(UICollectionView *)collectionView {
[collectionView registerClass:self forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:[self identifier]];
}
+ (void)registerNibFooterForCollectionView:(UICollectionView *)collectionView {
[collectionView registerNib:[UINib nibWithNibName:[self className]
bundle:[NSBundle mainBundle]] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:[self identifier]];
}
+ (void)registerNibHeaderForCollectionView:(UICollectionView *)collectionView {
[collectionView registerNib:[UINib nibWithNibName:[self className]
bundle:[NSBundle mainBundle]] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[self identifier]];
}
+ (void)registerClassHeaderForCollectionView:(UICollectionView *)collectionView {
[collectionView registerClass:self forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[self identifier]];
}
+ (instancetype)dequeueReusableSupplementaryHeaderViewOfKind:(UICollectionView *)collectionView index:(NSIndexPath *)indexPath{
return [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[self identifier] forIndexPath:indexPath];
}
+ (instancetype)dequeueReusableSupplementaryFooterViewOfKind:(UICollectionView *)collectionView index:(NSIndexPath *)indexPath {
return [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:[self identifier] forIndexPath:indexPath];
}
+ (NSString *)identifier {
return [NSString stringWithFormat:@"%@Id",[self className]];
}
+ (NSString *)className {
return NSStringFromClass(self);
}
@end
//
// UICollectionViewCell+Extension.h
// xiangwan
//
// Created by mac on 2019/8/17.
// Copyright © 2019 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UICollectionViewCell (Extension)
/// cell Class注册方法
+ (void)registerClassForCollectionView:(UICollectionView *)collectionView;
/// cell Nib注册方法
+ (void)registerNibForCollectionView:(UICollectionView *)collectionView;
+ (NSString *)identifier;
@end
NS_ASSUME_NONNULL_END
//
// UICollectionViewCell+Extension.m
// xiangwan
//
// Created by mac on 2019/8/17.
// Copyright © 2019 mac. All rights reserved.
//
#import "UICollectionViewCell+Extension.h"
@implementation UICollectionViewCell (Extension)
+ (void)registerClassForCollectionView:(UICollectionView *)collectionView {
[collectionView registerClass:self forCellWithReuseIdentifier:[self identifier]];
}
+ (void)registerNibForCollectionView:(UICollectionView *)collectionView {
[collectionView registerNib:[UINib nibWithNibName:[self className]
bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:[self identifier]];
}
+ (NSString *)identifier {
return [NSString stringWithFormat:@"%@Id",[self className]];
}
+ (NSString *)className {
return NSStringFromClass(self);
}
@end
//
// UITableViewCell+Extension.h
// xiangwan
//
// Created by mac on 2019/8/17.
// Copyright © 2019 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UITableViewCell (Extension)
/// cell Class注册方法
+ (void)registerClassForTableView:(UITableView *)tableView;
/// cell Nib注册方法
+ (void)registerNibForTableView:(UITableView *)tableView;
+ (NSString *)identifier;
@end
NS_ASSUME_NONNULL_END
//
// UITableViewCell+Extension.m
// xiangwan
//
// Created by mac on 2019/8/17.
// Copyright © 2019 mac. All rights reserved.
//
#import "UITableViewCell+Extension.h"
@implementation UITableViewCell (Extension)
+ (void)registerClassForTableView:(UITableView *)tableView {
[tableView registerClass:self forCellReuseIdentifier:[self identifier]];
}
+ (void)registerNibForTableView:(UITableView *)tableView {
[tableView registerNib:[UINib nibWithNibName:[self className]
bundle:[NSBundle mainBundle]] forCellReuseIdentifier:[self identifier]];
}
+ (NSString *)identifier {
return [NSString stringWithFormat:@"%@Id",[self className]];
}
+ (NSString *)className {
return NSStringFromClass(self);
}
@end
//
// UITableViewHeaderFooterView+Extension.h
// xiangwan
//
// Created by mac on 2019/10/8.
// Copyright © 2019 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UITableViewHeaderFooterView (Extension)
/// Class注册方法
+ (void)registerClassHeaderFooterForTableView:(UITableView *)tableView;
/// Nib注册方法
+ (void)registerNibHeaderFooterForTableView:(UITableView *)tableView;
+ (NSString *)identifier;
@end
NS_ASSUME_NONNULL_END
//
// UITableViewHeaderFooterView+Extension.m
// xiangwan
//
// Created by mac on 2019/10/8.
// Copyright © 2019 mac. All rights reserved.
//
#import "UITableViewHeaderFooterView+Extension.h"
@implementation UITableViewHeaderFooterView (Extension)
+ (void)registerClassHeaderFooterForTableView:(UITableView *)tableView {
[tableView registerClass:self forHeaderFooterViewReuseIdentifier:[self identifier]];
}
+ (void)registerNibHeaderFooterForTableView:(UITableView *)tableView {
[tableView registerNib:[UINib nibWithNibName:[self className]
bundle:[NSBundle mainBundle]] forHeaderFooterViewReuseIdentifier:[self identifier]];
}
+ (NSString *)identifier {
return [NSString stringWithFormat:@"%@Id",[self className]];
}
+ (NSString *)className {
return NSStringFromClass(self);
}
@end
//
// UIImage+Extension.h
// xiangwan
//
// Created by mac on 2019/8/5.
// Copyright © 2019 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIImage (Extension)
+ (UIImage *)imageWithColor:(UIColor *)color;
// 生成二维码
+ (UIImage *)generateQRCode:(NSString *)code size:(CGSize)size;
//生成一个圆角图片
- (UIImage *)circleImage;
///毛玻璃
- (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur;
///根据颜色和圆的半径来创建一个圆形图片
+ (UIImage *)createImageWithColor:(UIColor *)color radius:(CGFloat)radius;
///根据一个view来创建一个 Image
+ (UIImage*)creatImageWithView:(UIView *)theView;
/**
图片组 本地
@param array 原生image arr
@param bgColor 新生成image 背景色
@return image 组合
*/
+ (UIImage *)groupIconWith:(NSArray *)array bgColor:(UIColor *)bgColor;
/**
图片组 本地
@param corner 新生成组合图片背景圆角
@param array 原生image arr
@param bgColor 新生成image 背景色
@return image 组合
*/
+ (UIImage *)groupIconWith:(NSArray *)array corner:(CGFloat)corner bgColor:(UIColor *)bgColor;
/**
图片组合 网络请求,使用SD缓存到本地磁盘,请求前先去缓存中哈希查找是否有缓存
@param URLArray 图片url 数组
@param corner 新生成组合图片背景圆角
@param bgColor 新生成组合图片背景颜色
@param Success 组合成功回调
@param Failed 组合失败回调
*/
+ (void )groupIconWithURLArray:(NSArray *)URLArray
corner:(CGFloat)corner
bgColor:(UIColor *)bgColor
Success:(void(^)(UIImage *image))Success
Failed:(void(^)(NSString *fail))Failed;
/**
图片组合 网络请求,使用SD缓存到本地磁盘,请求前先去缓存中哈希查找是否有缓存
@param URLArray 图片url 数组
@param bgColor 新生成组合图片背景颜色
@param Success 组合成功回调
@param Failed 组合失败回调
*/
+ (void)groupIconWithURLArray:(NSArray *)URLArray
bgColor:(UIColor *)bgColor
Success:(void(^)(UIImage *image))Success
Failed:(void(^)(NSString *fail))Failed;
/// 旋转90度
- (UIImage *)normalizedImage;
/// 压缩图片使图片文件小于指定大小
- (NSData *)compressWithMaxLength:(NSUInteger)maxLength;
/**
缓存图片到SDWebImage
@param url 图片url(如:files/activityPic/xxxx/xxx.jpg)
*/
- (void)cacheImageWithUrl:(NSString *)url;
@end
NS_ASSUME_NONNULL_END
This diff is collapsed.
//
// AttributLabel.h
// CQ_App
//
// Created by mac on 2019/6/25.
// Copyright © 2019 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface AttributLabel : UILabel
@property (nonatomic, strong) NSString *htmlString;
@property (nonatomic, strong) NSString *solidString;
@property (nonatomic, strong) NSString *shadowString;
-(void)setUnderlineForString:(NSString *)string
underline:(NSString *)underline
underlineColor:(UIColor *)color;
/// 删除线
-(void)setStrikethroughForString:(NSString *)string
strikethroughText:(NSString *)text
strikethroughColor:(UIColor *)color;
-(void)setIconForString:(NSString *)string
image:(UIImage *)image;
-(void)setColorForString:(NSString *)string
colorString:(NSString *)colorString
colorStringColor:(UIColor *)color;
-(void)setShadowString:(NSString *)string offset:(CGSize)size;
@end
NS_ASSUME_NONNULL_END
//
// AttributLabel.m
// CQ_App
//
// Created by mac on 2019/6/25.
// Copyright © 2019 mac. All rights reserved.
//
#import "AttributLabel.h"
#import "MacroDefinition.h"
@implementation AttributLabel
-(void)setSolidString:(NSString *)solidString {
_solidString = solidString;
NSAttributedString *attrStr = [[NSAttributedString alloc]initWithString:solidString attributes: @{NSFontAttributeName:FONTSIZE(12.0f),NSForegroundColorAttributeName:[UIColor redColor],NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid),NSStrikethroughColorAttributeName:[UIColor redColor]}];
self.attributedText = attrStr;
}
-(void)setHtmlString:(NSString *)htmlString {
_htmlString = htmlString;
self.numberOfLines = 0;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSFontAttributeName:FONTSIZE(14)} documentAttributes:nil error:nil];
self.attributedText = attributedString;
}
-(void)setShadowString:(NSString *)shadowString {
_shadowString = shadowString;
if (shadowString == nil) {
return;
}
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowBlurRadius = 2;
shadow.shadowColor = [UIColor blackColor];
shadow.shadowOffset = CGSizeMake(0,0);
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:shadowString attributes: @{NSFontAttributeName: self.font,NSForegroundColorAttributeName: [UIColor whiteColor], NSShadowAttributeName: shadow}];
self.attributedText = attributedString;
}
-(void)setShadowString:(NSString *)string offset:(CGSize)size {
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowBlurRadius = 0;
shadow.shadowColor = RGBACOLOR(0, 0, 0, 0.5);
shadow.shadowOffset = size;
NSMutableAttributedString *atString = [[NSMutableAttributedString alloc] initWithString:string attributes: @{NSFontAttributeName: self.font,NSForegroundColorAttributeName: [UIColor whiteColor], NSShadowAttributeName: shadow}];
self.attributedText = atString;
}
-(void)setUnderlineForString:(NSString *)string underline:(NSString *)underline underlineColor:(UIColor *)color{
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:string];
NSRange range = [[attribtStr string] rangeOfString:underline];
// 下划线
[attribtStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:range];
[attribtStr addAttribute:NSForegroundColorAttributeName value:color range:range];
//赋值
self.attributedText = attribtStr;
}
-(void)setStrikethroughForString:(NSString *)string
strikethroughText:(NSString *)text
strikethroughColor:(UIColor *)color {
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:string];
NSDictionary <NSAttributedStringKey, id>*attributes = @{NSFontAttributeName:FONTSIZE(11),NSForegroundColorAttributeName:color,
NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid),NSStrikethroughColorAttributeName:color};
NSRange range = [[attribtStr string] rangeOfString:text];
[attribtStr addAttributes:attributes range:range];
self.attributedText = attribtStr;
}
-(void)setIconForString:(NSString *)string
image:(UIImage *)image {
@autoreleasepool {
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:string];
NSTextAttachment *textAtt = [[NSTextAttachment alloc]init];
textAtt.image = image;
textAtt.bounds = CGRectMake(0, -3,30,15);
NSAttributedString* textAttString = [NSAttributedString attributedStringWithAttachment:textAtt];
//将图片放在第一位
[attri insertAttributedString:textAttString atIndex:0];
self.attributedText = attri;
}
}
-(void)setColorForString:(NSString *)string colorString:(NSString *)colorString colorStringColor:(UIColor *)color{
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:string];
NSRange range = [[attribtStr string] rangeOfString:colorString];
[attribtStr addAttribute:NSForegroundColorAttributeName value:color range:range];
//赋值
self.attributedText = attribtStr;
}
@end
//
// NMSearchBar.h
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface NMSearchBar : UITextField
@end
NS_ASSUME_NONNULL_END
//
// NMSearchBar.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import "NMSearchBar.h"
@implementation NMSearchBar
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "delete.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "group_portrait.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "group_portrait@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "group_portrait@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "index.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "index1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "search.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "gouwu.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "gouwu1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="138" y="75"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// main.m
// Mall-iOS
//
// Created by Nemo on 2020/10/12.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}
//
// ViewControllerConfigure.h
// CQ_App
//
// Created by mac on 2019/3/22.
// Copyright © 2019年 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ViewControllerConfigure : NSObject
@end
NS_ASSUME_NONNULL_END
//
// ViewControllerConfigure.m
// CQ_App
//
// Created by mac on 2019/3/22.
// Copyright © 2019年 mac. All rights reserved.
//
#import "ViewControllerConfigure.h"
#import "MacroDefinition.h"
#import <Aspects.h>
@implementation ViewControllerConfigure
+(void)load {
[super load];
/**
kDISPATCH_AFTER(0.5, ^{
[ViewControllerConfigure sharedInstance];
});
*/
}
+ (instancetype)sharedInstance
{
static dispatch_once_t onceToken;
static ViewControllerConfigure *sharedInstance;
dispatch_once(&onceToken, ^{
sharedInstance = [[ViewControllerConfigure alloc] init];
});
return sharedInstance;
}
- (instancetype)init
{
self = [super init];
if (self) {
/* 在这里做好方法拦截
[UIViewController aspect_hookSelector:@selector(loadView) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo>aspectInfo){
[self loadView:[aspectInfo instance]];
} error:NULL];*/
[UIViewController aspect_hookSelector:@selector(viewWillAppear:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo, BOOL animated){
[self viewWillAppear:animated viewController:[aspectInfo instance]];
} error:NULL];
[UIViewController aspect_hookSelector:@selector(viewDidLoad) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo) {
[self viewDidLoadViewController:[aspectInfo instance]];
} error:NULL];
/**
[UIViewController aspect_hookSelector:@selector(viewDidDisappear:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo, BOOL animated){
[self viewDidDisappear:animated viewController:[aspectInfo instance]];
} error:NULL];
[UIViewController aspect_hookSelector:@selector(viewDidAppear:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo, BOOL animated){
[self viewDidAppear:animated viewController:[aspectInfo instance]];
} error:NULL];*/
}
return self;
}
/*
下面的这些方法中就可以做到自动拦截了。
所以在你原来的架构中,大部分封装UIViewController的基类或者其他的什么基类,都可以使用这种方法让这些基类消失。
*/
#pragma mark - fake methods
- (void)viewDidDisappear:(BOOL)animated viewController:(UIViewController *)viewController {}
- (void)viewDidAppear:(BOOL)animated viewController:(UIViewController *)viewController {}
- (void)viewWillAppear:(BOOL)animated viewController:(UIViewController *)viewController {
/* 你可以使用这个方法进行打日志,初始化基础业务相关的内容 */
//NSLog(@"%@ viewWillAppear",viewController.className);
}
- (void)viewDidLoadViewController:(UIViewController *)viewController {
/* 你可以使用这个方法进行打日志,初始化基础业务相关的内容 */
//NSLog(@"%@ viewDidLoad",viewController.className);
[self setupViewsViewController:viewController];
// 判断是否有上级页面,有的话再调用
if ([viewController.navigationController.viewControllers indexOfObject:viewController] > 0) {
[self setupLeftBarButtonViewController:viewController];
}
}
- (void)setupViewsViewController:(UIViewController *)viewController {
// 设置应用的背景色
if ((![viewController.class isKindOfClass:[UIViewController class]])) {
viewController.view.backgroundColor = [UIColor whiteColor];
}
}
- (void)setupLeftBarButtonViewController:(UIViewController *)viewController{
// 自定义 leftBarButtonItem ,UIImageRenderingModeAlwaysOriginal 防止图片被渲染
viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:[[UIImage imageNamed:@"public_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
style:UIBarButtonItemStylePlain
target:self action:@selector(leftBarButtonClick)];
}
#pragma mark - 返回按钮的点击事件
- (void)leftBarButtonClick {
//[[[AppDelegate shareAppDelegate] currentViewController].navigationController popViewControllerAnimated:YES];
}
@end
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
source 'http://git.changein.cn/xzc168520/pwspecs.git'
target 'Mall-iOS' do
pod 'MJRefresh'
pod 'Masonry'
pod 'ReactiveObjC'
pod 'MLeaksFinder', :configurations => ['Debug']
pod 'Aspects'
pod 'FBMemoryProfiler'
pod 'NMRouter'
pod 'SDCycleScrollView','1.80'
pod 'QMUIKit'
end
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