- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = SynopticNetworkColorFromRGB(0x1D1E1F);
[self setSynopticNetworkPluginViewTypeHorizontal];
[self setSynopticNetworkPluginViewTypeLeftLarge];
[self setSynopticNetworkPluginViewTypeRightLarge];
[self setSynopticNetworkPluginViewTypeVertical];
}
//显示横向单排
-(void)setSynopticNetworkPluginViewTypeHorizontal{
[self showViewWithFrame:CGRectMake(0, [[UIApplication sharedApplication] statusBarFrame].size.height + 44.f, self.view.frame.size.width, 20) Type:SynopticNetworkPluginViewTypeHorizontal typeArray:
@[@(SynopticNetworkConfigModelTypeLocation),
@(SynopticNetworkConfigModelTypeAlarmIcon),
@(SynopticNetworkConfigModelTypeAlarm),
@(SynopticNetworkConfigModelTypeTemp),
@(SynopticNetworkConfigModelTypeWeatherStateIcon),
@(SynopticNetworkConfigModelTypeWeatherState),
@(SynopticNetworkConfigModelTypeWindDirIcon),
@(SynopticNetworkConfigModelTypeWindSC),
@(SynopticNetworkConfigModelTypeAqiTitle),
@(SynopticNetworkConfigModelTypeQlty),
@(SynopticNetworkConfigModelTypeAqi),
]];
}
//显示左侧大布局右侧双布局
-(void)setSynopticNetworkPluginViewTypeLeftLarge{
[self showViewWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 40) Type:SynopticNetworkPluginViewTypeLeftLarge typeArray:
@[
//第一个数组内元素会被放在左边大布局上
@[@(SynopticNetworkConfigModelTypeWeatherStateIcon)],
//第二个数组内元素会被放在右边上部分布局上
@[@(SynopticNetworkConfigModelTypeTemp),
@(SynopticNetworkConfigModelTypeAlarmIcon),
@(SynopticNetworkConfigModelTypeAlarm),
@(SynopticNetworkConfigModelTypeAqiTitle),
@(SynopticNetworkConfigModelTypeQlty),
@(SynopticNetworkConfigModelTypeAqi),
@(SynopticNetworkConfigModelTypeLocation)],
//第三个数组内元素会被放在右边下部分布局上
@[@(SynopticNetworkConfigModelTypeWeatherState),
@(SynopticNetworkConfigModelTypeWindDirIcon),
@(SynopticNetworkConfigModelTypeWindSC),
]]];
}
//显示右侧大布局左侧双布局
-(void)setSynopticNetworkPluginViewTypeRightLarge{
[self showViewWithFrame:CGRectMake(0, 300, self.view.frame.size.width, 40) Type:SynopticNetworkPluginViewTypeRightLarge typeArray:
@[
//第一个数组内元素会被放在右边大布局上
@[@(SynopticNetworkConfigModelTypeTemp)],
//第二个数组内元素会被放在左边上部分布局上
@[
@(SynopticNetworkConfigModelTypeLocation),
@(SynopticNetworkConfigModelTypeAqiTitle),
@(SynopticNetworkConfigModelTypeQlty),
@(SynopticNetworkConfigModelTypeAqi),
@(SynopticNetworkConfigModelTypeAlarmIcon),
@(SynopticNetworkConfigModelTypeAlarm),
@(SynopticNetworkConfigModelTypeWeatherStateIcon)],
//第三个数组内元素会被放在左边下部分布局上
@[
@(SynopticNetworkConfigModelTypeWindDirIcon),
@(SynopticNetworkConfigModelTypeWindSC),
@(SynopticNetworkConfigModelTypeWeatherState)]
]];
}
//显示竖向单排布局
-(void)setSynopticNetworkPluginViewTypeVertical{
[self showViewWithFrame:CGRectMake(0, 400, 50, 300) Type:SynopticNetworkPluginViewTypeVertical typeArray:@[@(SynopticNetworkConfigModelTypeLocation),
@(SynopticNetworkConfigModelTypeTemp),
@(SynopticNetworkConfigModelTypeWeatherStateIcon),
@(SynopticNetworkConfigModelTypeWeatherState),
@(SynopticNetworkConfigModelTypeWindDirIcon),
@(SynopticNetworkConfigModelTypeWindSC),
@(SynopticNetworkConfigModelTypeAqiTitle),
@(SynopticNetworkConfigModelTypeQlty),
@(SynopticNetworkConfigModelTypeAqi),
@(SynopticNetworkConfigModelTypeAlarmIcon),
@(SynopticNetworkConfigModelTypeAlarm),
]];
}
-(void)showViewWithFrame:(CGRect)frame Type:(SynopticNetworkPluginViewType)type typeArray:(NSArray *)typeArray{
//初始化视图
SynopticNetworkPluginView *view = [[SynopticNetworkPluginView alloc] initWithFrame:frame ViewType:type UserKey:@"用户key" Location:@"101010100"];
//视图属性设置
NSMutableArray *configarray = [NSMutableArray array];
[typeArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSMutableArray *modelarray = [NSMutableArray array];
if ([obj isKindOfClass:[NSArray class]]) {
[obj enumerateObjectsUsingBlock:^(id _Nonnull arrayobj, NSUInteger idx, BOOL * _Nonnull stop) {
SynopticNetworkConfigModel *model = [SynopticNetworkConfigModel new];
if (idx==0&&[arrayobj integerValue]==SynopticNetworkConfigModelTypeTemp&&[obj count]==1) {
model.textFont = [UIFont systemFontOfSize:40];
}
if (idx==0&&[arrayobj integerValue]==SynopticNetworkConfigModelTypeWeatherStateIcon&&[obj count]==1) {
model.iconSize = 32;
}
model.type = [arrayobj integerValue];
model.padding =type==SynopticNetworkPluginViewTypeVertical? UIEdgeInsetsMake(8, 4, 8, 4):UIEdgeInsetsMake(4, 8, 4, 8);
[modelarray addObject:model];
}];
[configarray addObject:modelarray];
}else{
SynopticNetworkConfigModel *model = [SynopticNetworkConfigModel new];
model.type = [obj integerValue];
model.padding =type==SynopticNetworkPluginViewTypeVertical? UIEdgeInsetsMake(8, 4, 8, 4):UIEdgeInsetsMake(4, 8, 4, 8);
[configarray addObject:model];
}
}];
//配置子元素排列顺序和属性
view.configArray = configarray;
view.contentViewAlignmen = SynopticNetworkContentViewAlignmentCenter;
//配置主题样式
view.themType = SynopticNetworkPluginViewThemeTypeAuto;
//配置视图内间距
view.padding = UIEdgeInsetsZero;
//配置视图背景颜色
view.backgroundColor = SynopticNetworkColorFromRGB(0xFAFAFA);
//自定义视图背景图片
view.backgroundImageTitle = @"";
//配置边框颜色
view.borderColor = [UIColor greenColor];
//配置边框宽度
view.borderWidth =2;
//配置圆角
view.cornerRadius = 2;
//是否显示边框
view.isShowBorder = NO;
//是否显示圆角
view.isShowConer = NO;
//拖拽设置
view.dragEnable = YES;
//拖拽范围
view.freeRect = self.view.frame;
//拖拽方向
view.dragDirection = SynopticNetworkPluginViewDragDirectionAny;
//是否粘边
view.isKeepBounds = YES;
//设置导航栏背景色
view.navigationBarBackgroundColor = [UIColor redColor];
//设置导航栏进度条背景色
view.progressColor = [UIColor blueColor];
//设置导航栏返回按钮图片
view.navBarBackImage = [UIImage imageNamed:@""];
//设置导航栏关闭图片
view.navBarCloseImage = [UIImage imageNamed:@""];
//添加视图到view上
[self.view addSubview:view];
}