Skip to content

A fast, convenient view to show animation select address view, similar to jd and taobao address selection components.

License

Notifications You must be signed in to change notification settings

Abnerzj/ZJAddressPickerView

Repository files navigation

ZJAddressPickerView

Platform Language License Weibo Jianshu

  • A fast, convenient view to show animation select address view, similar to Taobao and JD address selection components.【一个快速、方便的视图,显示动画选择地址视图,类似于淘宝和京东的地址选择组件。】

---

Getting Started【开始使用】

Features【能做什么】

  • 类似于淘宝和京东的地址选择组件。
  • 支持从网络加载数据回传。
  • 增加修改地址功能。
  • 支持自定义配置,主题色、渐变等。
  • 支持地址5级联动,本地数据只有4级。

Installation【安装】

From CocoaPods【使用CocoaPods】

pod 'ZJAddressPickerView'

Manually【手动导入】

  • Drag all source files under floder ZJAddressPickerView to your project.【将ZJAddressPickerView文件夹中的所有源代码拽入项目中】
  • Import the main header file:#import "ZJAddressPickerView.h"【导入主头文件:#import "ZJAddressPickerView.h"
ZJAddressPickerView.h                      
ZJAddressPickerView.m
ZJAreaProvider.h
ZJAreaProvider.m
ZJAddressPickerView.bundle

Examples【示例】

Direct Use【直接使用】

// 1.初始化
ZJAddressPickerView *addressView = [ZJAddressPickerView new];
// 2.显示弹框
[addressView show];

User-defined properties【自定义想要的效果】

// 1.Init config,can not be set【初始化配置,可不设置使用默认值,见注解】
ZJAddressConfig *addressConfig = [ZJAddressConfig new];

// 1.1 可选级别(默认4级,可达5级,本地数据源只支持4级联动数据)
addressConfig.maxLevels = 4;
// 1.2 标题
addressConfig.title = @"请选择地址";
// 1.3 取消按钮
addressConfig.cancel = @"取消";
// 1.4 主题色
addressConfig.themColor = UIColor.redColor;
// 1.5 文本颜色
addressConfig.textColor = UIColor.blackColor;
// 1.6 选中结果文本颜色
addressConfig.selectTextColor = UIColor.redColor;
// 1.7 设置是否线条渐变,跟themColor相关连
addressConfig.isGradientLine = YES;
// 1.8 弹窗高度
addressConfig.viewHeight = 400;

// 2.Init【初始化】
ZJAddressPickerView *addressView = [ZJAddressPickerView new];

// 3.Set config,can not be set【设置配置】
addressView.addressConfig = addressConfig;

// 3.1 Load data from the network, user implementation【从网络加载数据,用户自定义实现】
[self loadNetworkData:^(NSArray<ZJAreaData *> *list) {
    addressView.areaProvider.sourceList = list;
}];

// 3.2 Selected address data【已选择的地址数据】
addressView.areaProvider.selectedSources = @[@"广东省", @"深圳市", @"南山区", @"粤海街道"];

// 3.6 Callback after selecting address data【选择完地址数据后回调】
__weak typeof(self) ws = self;
addressView.completion = ^(NSArray<ZJAreaData *> * _Nonnull list) {
    __strong typeof(self) self = ws;
    NSMutableString *address = [NSMutableString new];
    [list enumerateObjectsUsingBlock:^(ZJAreaData * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj.name isEqualToString:@""]) {
            NSLog(@"联动数据不够,已用空数据处理");
        }
        [address appendString:obj.name];
        if (idx < list.count - 1) {
            [address appendString:@" "];
        }
    }];
    NSLog(@"address = %@", address);
};

// 4.pop view【显示弹框】
[addressView show];

期待

  • 如果在使用过程中遇到BUG,请Issues我,谢谢。
  • 如果你想为ZJAddressPickerView输出代码,请拼命Pull Requests我,让更多的老铁们都能使用到你那吊炸天的动画效果。
  • 感谢IHAddressView,Swift版本请参考。
  • 联系我😯 :简书 微博

About

A fast, convenient view to show animation select address view, similar to jd and taobao address selection components.

Resources

License

Stars

Watchers

Forks

Packages