Commit 2b5e2a0a9dec77b1193c9616840b4649d0fc19b3
1 parent
39971576
no message
Showing
7 changed files
with
438 additions
and
9 deletions
CNLiveSettingModule.podspec
| @@ -44,6 +44,8 @@ TODO: 网家家-设置模块. | @@ -44,6 +44,8 @@ TODO: 网家家-设置模块. | ||
| 44 | ss.dependency 'CNLiveSettingModule/Privacy' | 44 | ss.dependency 'CNLiveSettingModule/Privacy' |
| 45 | ss.dependency 'CNLiveSettingModule/AboutUs' | 45 | ss.dependency 'CNLiveSettingModule/AboutUs' |
| 46 | ss.dependency 'CNLiveSettingModule/Cancellation' | 46 | ss.dependency 'CNLiveSettingModule/Cancellation' |
| 47 | + ss.dependency 'CNLiveSettingModule/FontSize' | ||
| 48 | + ss.dependency 'CNLiveSettingModule/BackgroundImage' | ||
| 47 | 49 | ||
| 48 | end | 50 | end |
| 49 | 51 | ||
| @@ -85,8 +87,13 @@ TODO: 网家家-设置模块. | @@ -85,8 +87,13 @@ TODO: 网家家-设置模块. | ||
| 85 | # 设置字体大小 | 87 | # 设置字体大小 |
| 86 | s.subspec 'FontSize' do |ss| | 88 | s.subspec 'FontSize' do |ss| |
| 87 | ss.source_files = 'CNLiveSettingModule/Classes/FontSize/*.{h,m}' | 89 | ss.source_files = 'CNLiveSettingModule/Classes/FontSize/*.{h,m}' |
| 88 | - ss.dependency 'CNLiveBaseKit' | ||
| 89 | - | 90 | + ss.dependency 'CNLiveSettingModule/View' |
| 91 | + end | ||
| 92 | + | ||
| 93 | + # 聊天背景图片 | ||
| 94 | + s.subspec 'BackgroundImage' do |ss| | ||
| 95 | + ss.source_files = 'CNLiveSettingModule/Classes/BackgroundImage/*.{h,m}' | ||
| 96 | + ss.dependency 'CNLiveSettingModule/View' | ||
| 90 | end | 97 | end |
| 91 | 98 | ||
| 92 | s.resource_bundles = { | 99 | s.resource_bundles = { |
| @@ -118,4 +125,13 @@ TODO: 网家家-设置模块. | @@ -118,4 +125,13 @@ TODO: 网家家-设置模块. | ||
| 118 | # 用户协议 | 125 | # 用户协议 |
| 119 | s.dependency 'CNLiveUserAgreementManager' | 126 | s.dependency 'CNLiveUserAgreementManager' |
| 120 | 127 | ||
| 128 | + s.dependency 'CNLiveBaseKit' | ||
| 129 | + | ||
| 130 | + | ||
| 131 | + s.dependency 'CNLiveImagePickerController' | ||
| 132 | + s.dependency 'CNLiveAVCamera' | ||
| 133 | + s.dependency 'CNLiveBusinessTools' | ||
| 134 | + | ||
| 135 | + s.static_framework = true | ||
| 136 | + | ||
| 121 | end | 137 | end |
CNLiveSettingModule/Classes/BackgroundImage/CNLiveBackgroundImageController.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveBackgroundImageController.h | ||
| 3 | +// CNLiveSettingModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 聊天背景 | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +#import <UIKit/UIKit.h> | ||
| 14 | + | ||
| 15 | +NS_ASSUME_NONNULL_BEGIN | ||
| 16 | +@class IMAUser; | ||
| 17 | + | ||
| 18 | +@interface CNLiveBackgroundImageController : UIViewController | ||
| 19 | +@property (nonatomic, strong) IMAUser *user; //设置单个聊天背景图才需要传 | ||
| 20 | +@property (nonatomic, assign) BOOL isSettingAll; //是否是设置所有聊天背景图 | ||
| 21 | + | ||
| 22 | +@end | ||
| 23 | + | ||
| 24 | +NS_ASSUME_NONNULL_END |
CNLiveSettingModule/Classes/BackgroundImage/CNLiveBackgroundImageController.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveBackgroundImageController.m | ||
| 3 | +// CNLiveSettingModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveBackgroundImageController.h" | ||
| 10 | +#import "MJExtension.h" | ||
| 11 | +#import <SDWebImage/SDWebImage.h> | ||
| 12 | +#import "QMUIKit.h" | ||
| 13 | + | ||
| 14 | +#import <AVFoundation/AVCaptureDevice.h> | ||
| 15 | +#import <AVFoundation/AVMediaFormat.h> | ||
| 16 | +#import "XFCameraController.h" | ||
| 17 | +#import "TZImagePickerController.h" | ||
| 18 | +#import "CNLiveBusinessTools.h" | ||
| 19 | +#import "CNLiveSettingModel.h" | ||
| 20 | +#import "CNLiveSettingCell.h" | ||
| 21 | +#import "CNLiveServices.h" | ||
| 22 | +#import "CNLiveSettingNavigationBar.h" | ||
| 23 | + | ||
| 24 | +@interface CNLiveBackgroundImageController () | ||
| 25 | +<UITableViewDelegate, UITableViewDataSource, CNLiveSettingNavigationBarDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate>{ | ||
| 26 | + UIImage *_selectedImage;// 当 isSettingAll为 YES 才需要用到 | ||
| 27 | +} | ||
| 28 | +@property (nonatomic, strong) CNLiveSettingNavigationBar *navigationBar; | ||
| 29 | +@property (nonatomic, strong) UITableView *tableView; | ||
| 30 | +@property (nonatomic, strong) UIButton *setting; | ||
| 31 | +@property (nonatomic, strong) NSMutableArray *data; | ||
| 32 | + | ||
| 33 | +@end | ||
| 34 | + | ||
| 35 | +@implementation CNLiveBackgroundImageController | ||
| 36 | +static const NSInteger timeValue = 1.5; | ||
| 37 | + | ||
| 38 | +#pragma mark - 加载数据 | ||
| 39 | +- (void)loadData { | ||
| 40 | + NSArray *data = @[ | ||
| 41 | + @{ | ||
| 42 | + @"style":@"1", | ||
| 43 | + @"title":@"从手机相册选择", | ||
| 44 | + @"height":@"60", | ||
| 45 | + @"lineHeight":@"10" | ||
| 46 | + }, | ||
| 47 | + @{ | ||
| 48 | + @"style":@"1", | ||
| 49 | + @"title":@"拍一张", | ||
| 50 | + @"height":@"60", | ||
| 51 | + @"lineHeight":@"10" | ||
| 52 | + }, | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + ]; | ||
| 56 | + for(NSDictionary *dic in data){ | ||
| 57 | + [self.data addObject:[CNLiveSettingModel mj_objectWithKeyValues:dic]]; | ||
| 58 | + } | ||
| 59 | + [self.tableView reloadData]; | ||
| 60 | + | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +#pragma mark - 生命周期 | ||
| 64 | +- (void)viewWillAppear:(BOOL)animated{ | ||
| 65 | + [super viewWillAppear:animated]; | ||
| 66 | + self.navigationController.navigationBarHidden = YES; | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +- (void)viewDidLoad { | ||
| 70 | + [super viewDidLoad]; | ||
| 71 | + self.view.backgroundColor = [UIColor whiteColor]; | ||
| 72 | + if (@available(iOS 11, *)) { | ||
| 73 | + self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; | ||
| 74 | + } | ||
| 75 | + else { | ||
| 76 | + self.automaticallyAdjustsScrollViewInsets = NO; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + [self createSubViews]; | ||
| 80 | + [self loadData]; | ||
| 81 | + | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +- (void)dealloc { | ||
| 85 | + | ||
| 86 | + | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +- (void)createSubViews { | ||
| 90 | + [self.view addSubview:self.navigationBar]; | ||
| 91 | + [self.view addSubview:self.tableView]; | ||
| 92 | + [self.view addSubview:self.setting]; | ||
| 93 | + | ||
| 94 | +} | ||
| 95 | +#pragma mark - UITableViewDelegate | ||
| 96 | +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | ||
| 97 | + CNLiveSettingModel *model = self.data[indexPath.row]; | ||
| 98 | + return model.height; | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +#pragma mark - UITableViewDataSource | ||
| 102 | +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | ||
| 103 | + return self.data.count; | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
| 107 | + CNLiveSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNLiveSettingCell]; | ||
| 108 | + cell.selectionStyle = UITableViewCellSelectionStyleNone; | ||
| 109 | + CNLiveSettingModel *model = self.data[indexPath.row]; | ||
| 110 | + cell.model = model; | ||
| 111 | + return cell; | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | ||
| 115 | + if(indexPath.row == 0){ | ||
| 116 | + TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self]; | ||
| 117 | + picker.modalPresentationStyle = UIModalPresentationFullScreen; | ||
| 118 | + picker.allowPickingVideo = NO; | ||
| 119 | + picker.allowPreview = NO; | ||
| 120 | + __weak typeof(self) weakSelf = self; | ||
| 121 | + [picker setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { | ||
| 122 | + __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 123 | + if(!strongSelf) return ; | ||
| 124 | + if (strongSelf.isSettingAll) { | ||
| 125 | + strongSelf->_selectedImage = [photos firstObject]; | ||
| 126 | + } | ||
| 127 | + else{ | ||
| 128 | + [strongSelf saveImage:[photos firstObject]]; | ||
| 129 | + } | ||
| 130 | + }]; | ||
| 131 | + [self presentViewController:picker animated:YES completion:nil]; | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + else if(indexPath.row == 1){ | ||
| 135 | + XFCameraController *cameraController = [[XFCameraController alloc] init]; | ||
| 136 | + cameraController.isCanShootVideo = NO; | ||
| 137 | + cameraController.modalPresentationStyle = UIModalPresentationFullScreen; | ||
| 138 | + __weak XFCameraController *weakCameraController = cameraController; | ||
| 139 | + __weak typeof(self) weakSelf = self; | ||
| 140 | + cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) { | ||
| 141 | + __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 142 | + if(!strongSelf) return ; | ||
| 143 | + if (strongSelf.isSettingAll) { | ||
| 144 | + strongSelf->_selectedImage = image; | ||
| 145 | + } | ||
| 146 | + else{ | ||
| 147 | + [strongSelf saveImage:image]; | ||
| 148 | + } | ||
| 149 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 150 | + [weakCameraController dismissViewControllerAnimated:YES completion:nil]; | ||
| 151 | + }); | ||
| 152 | + }; | ||
| 153 | + [self presentViewController:cameraController animated:YES completion:nil]; | ||
| 154 | + | ||
| 155 | + } | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +#pragma mark - 懒加载 | ||
| 159 | +- (NSMutableArray *)data { | ||
| 160 | + if (!_data) { | ||
| 161 | + _data = [NSMutableArray array]; | ||
| 162 | + } | ||
| 163 | + return _data; | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | +- (CNLiveSettingNavigationBar *)navigationBar { | ||
| 167 | + if (!_navigationBar) { | ||
| 168 | + _navigationBar = [[CNLiveSettingNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)]; | ||
| 169 | + _navigationBar.backgroundColor = [UIColor whiteColor]; | ||
| 170 | + _navigationBar.delegate = self; | ||
| 171 | + _navigationBar.title.text = @"聊天背景"; | ||
| 172 | + _navigationBar.right = nil; | ||
| 173 | + } | ||
| 174 | + return _navigationBar; | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | +- (UITableView *)tableView{ | ||
| 178 | + if(!_tableView){ | ||
| 179 | + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop-50) style:UITableViewStylePlain]; | ||
| 180 | + _tableView.delegate = self; | ||
| 181 | + _tableView.dataSource = self; | ||
| 182 | + _tableView.bounces = NO; | ||
| 183 | + _tableView.scrollEnabled = NO; | ||
| 184 | + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; | ||
| 185 | + _tableView.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0]; | ||
| 186 | + _tableView.estimatedRowHeight = 0; | ||
| 187 | + _tableView.estimatedSectionHeaderHeight = 0; | ||
| 188 | + _tableView.estimatedSectionFooterHeight = 0; | ||
| 189 | + [_tableView registerClass:[CNLiveSettingCell class] forCellReuseIdentifier:kCNLiveSettingCell]; | ||
| 190 | + } | ||
| 191 | + return _tableView; | ||
| 192 | +} | ||
| 193 | +- (UIButton *)setting{ | ||
| 194 | + if(!_setting){ | ||
| 195 | + _setting = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 196 | + _setting.frame = CGRectMake(0, SCREEN_HEIGHT-SafeAreaInsetsConstantForDeviceWithNotch.bottom-50, SCREEN_WIDTH, 50); | ||
| 197 | + _setting.backgroundColor = [UIColor whiteColor]; | ||
| 198 | + _setting.titleLabel.font = [UIFont systemFontOfSize:16.0]; | ||
| 199 | + [_setting setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 200 | + [_setting setTitle:@"将背景应用到所有聊天场景" forState:UIControlStateNormal]; | ||
| 201 | + _setting.adjustsImageWhenHighlighted = NO; | ||
| 202 | + [_setting addTarget:self action:@selector(settingDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 203 | + } | ||
| 204 | + return _setting; | ||
| 205 | +} | ||
| 206 | + | ||
| 207 | +#pragma mark - 响应方法 | ||
| 208 | +- (void)goBack { | ||
| 209 | + if (self.presentingViewController != nil) { | ||
| 210 | + [self dismissViewControllerAnimated:YES completion:nil]; | ||
| 211 | + } | ||
| 212 | + else { | ||
| 213 | + [self.navigationController popViewControllerAnimated:YES]; | ||
| 214 | + } | ||
| 215 | +} | ||
| 216 | +- (void)settingDidClicked:(UIButton *)btn{ | ||
| 217 | + if (_selectedImage == nil) { | ||
| 218 | + [QMUITips showError:@"请选择图片" inView:self.view hideAfterDelay:timeValue]; | ||
| 219 | + return; | ||
| 220 | + } | ||
| 221 | + QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"将背景应用到所有聊天场景" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | ||
| 222 | + | ||
| 223 | + | ||
| 224 | + }]; | ||
| 225 | + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | ||
| 226 | + }]; | ||
| 227 | + | ||
| 228 | + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet]; | ||
| 229 | + [alertController addAction:sure]; | ||
| 230 | + [alertController addAction:cancel]; | ||
| 231 | + | ||
| 232 | + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | ||
| 233 | + | ||
| 234 | + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | ||
| 235 | + | ||
| 236 | + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | ||
| 237 | + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; | ||
| 238 | + | ||
| 239 | + sure.buttonAttributes = titleAttributs; | ||
| 240 | + cancel.buttonAttributes = cancelAttributs; | ||
| 241 | + | ||
| 242 | + [alertController showWithAnimated:YES]; | ||
| 243 | + | ||
| 244 | +} | ||
| 245 | + | ||
| 246 | +#pragma mark - 私有方法 | ||
| 247 | +- (void)saveImage:(UIImage *)image { | ||
| 248 | + NSData *data = UIImagePNGRepresentation(image); | ||
| 249 | + if (data.length > 10*1024.0*1024.0) { | ||
| 250 | + [QMUITips showError:@"图片太大,请重新选择" inView:self.view hideAfterDelay:timeValue]; | ||
| 251 | + return ; | ||
| 252 | + } | ||
| 253 | +// NSString *fileName = [NSString stringWithFormat:@"%ld_backgroupImage",(long)[CNLiveTimeTools getNowTimestamp]]; | ||
| 254 | +// NSString *filePath = [[CNLiveBusinessTools chatBackgroupImagefilePath] stringByAppendingPathComponent:fileName]; | ||
| 255 | + NSString *filePath = @"asd"; | ||
| 256 | + | ||
| 257 | + [QMUITips showLoadingInView:self.view]; | ||
| 258 | + __weak typeof(self) weakSelf = self; | ||
| 259 | + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | ||
| 260 | + if ([data writeToFile:filePath atomically:YES]) { | ||
| 261 | + if(YES){ | ||
| 262 | +// if ([[CNChatBackgroundImageFMDBManager manager] searchChatBackgroupImage:_user.userId]){ | ||
| 263 | +// //先删除再添加 | ||
| 264 | +// CNChatBackgroupModel *oldModel = [[CNChatBackgroundImageFMDBManager manager] searchChatBackgroupImage:_user.userId]; | ||
| 265 | +// //并删除之前的背景图片 | ||
| 266 | +// NSString *oldFileName = [oldModel.imageFilePath lastPathComponent]; | ||
| 267 | +// if ([[NSFileManager defaultManager] fileExistsAtPath:[[CNLiveBusinessTools chatBackgroupImagefilePath] stringByAppendingPathComponent:oldFileName]]) { | ||
| 268 | +// | ||
| 269 | +// [[NSFileManager defaultManager] removeItemAtPath:[[CNLiveBusinessTools chatBackgroupImagefilePath] stringByAppendingPathComponent:oldFileName] error:nil]; | ||
| 270 | +// } | ||
| 271 | +// | ||
| 272 | +// [[CNChatBackgroundImageFMDBManager manager] deleteChatBackgroupImage:oldModel]; | ||
| 273 | +// | ||
| 274 | +// //保存新的数据 | ||
| 275 | +// CNChatBackgroupModel *newModel = [[CNChatBackgroupModel alloc] init]; | ||
| 276 | +// newModel.receiver = _user.userId; | ||
| 277 | +// newModel.imageFilePath = filePath; | ||
| 278 | +// [[CNChatBackgroundImageFMDBManager manager] insertChatBackgroupImage:newModel]; | ||
| 279 | + } | ||
| 280 | + else { | ||
| 281 | + //添加新数据 | ||
| 282 | +// CNChatBackgroupModel *model = [[CNChatBackgroupModel alloc] init]; | ||
| 283 | +// model.receiver = _user.userId; | ||
| 284 | +// model.imageFilePath = filePath; | ||
| 285 | +// [[CNChatBackgroundImageFMDBManager manager] insertChatBackgroupImage:model]; | ||
| 286 | + } | ||
| 287 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 288 | + [QMUITips hideAllToastInView:weakSelf.view animated:YES]; | ||
| 289 | + NSArray *array = [self.navigationController viewControllers]; | ||
| 290 | + for (UIViewController *vc in array) { | ||
| 291 | +// if ([vc isKindOfClass:[CNChatViewController class]]) { | ||
| 292 | +// [self.navigationController popToViewController:vc animated:YES]; | ||
| 293 | +// } | ||
| 294 | + } | ||
| 295 | + }); | ||
| 296 | + } | ||
| 297 | + else { | ||
| 298 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 299 | + [QMUITips hideAllToastInView:weakSelf.view animated:YES]; | ||
| 300 | + [QMUITips showError:@"保存失败,请重试" inView:weakSelf.view hideAfterDelay:timeValue]; | ||
| 301 | + }); | ||
| 302 | + } | ||
| 303 | + }); | ||
| 304 | +} | ||
| 305 | +/** | ||
| 306 | + * 创建图片 | ||
| 307 | + * | ||
| 308 | + * @param imageName 图片名字 | ||
| 309 | + * @param bundleName 图片所在的bundle名字 | ||
| 310 | + * @param targetClass 类和bundle的同级目录 | ||
| 311 | + * @return 返回UIImage | ||
| 312 | + */ | ||
| 313 | +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{ | ||
| 314 | + NSBundle *bundle = [NSBundle bundleForClass:targetClass]; | ||
| 315 | + NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"]; | ||
| 316 | + NSBundle *targetBundle = [NSBundle bundleWithURL:url]; | ||
| 317 | + UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil]; | ||
| 318 | + return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; | ||
| 319 | +} | ||
| 320 | + | ||
| 321 | +#pragma mark - CNLiveSettingNavigationBarDelegate | ||
| 322 | +- (void)navigationBar:(CNLiveSettingNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | ||
| 323 | + if ([actionEvents isEqualToString:@"1"]) { | ||
| 324 | + [self goBack]; | ||
| 325 | + }else if ([actionEvents isEqualToString:@"2"]){ | ||
| 326 | + | ||
| 327 | + } | ||
| 328 | +} | ||
| 329 | + | ||
| 330 | + | ||
| 331 | +@end |
CNLiveSettingModule/Classes/Controller/CNLiveSettingController.m
| @@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
| 22 | #import "CNLiveCancellationController.h"//注销 | 22 | #import "CNLiveCancellationController.h"//注销 |
| 23 | #import "CNLiveAboutUsController.h"//关于我们 | 23 | #import "CNLiveAboutUsController.h"//关于我们 |
| 24 | #import "CNLiveFontSettingController.h"//设置字体大小 | 24 | #import "CNLiveFontSettingController.h"//设置字体大小 |
| 25 | +#import "CNLiveBackgroundImageController.h" | ||
| 25 | 26 | ||
| 26 | @interface CNLiveSettingController () | 27 | @interface CNLiveSettingController () |
| 27 | <UITableViewDelegate, UITableViewDataSource, CNLiveSettingNavigationBarDelegate> | 28 | <UITableViewDelegate, UITableViewDataSource, CNLiveSettingNavigationBarDelegate> |
| @@ -74,6 +75,12 @@ static const NSInteger timeValue = 1.5; | @@ -74,6 +75,12 @@ static const NSInteger timeValue = 1.5; | ||
| 74 | }, | 75 | }, |
| 75 | @{ | 76 | @{ |
| 76 | @"style":@"1", | 77 | @"style":@"1", |
| 78 | + @"title":@"设置聊天背景图片", | ||
| 79 | + @"height":@"51", | ||
| 80 | + @"lineHeight":@"1" | ||
| 81 | + }, | ||
| 82 | + @{ | ||
| 83 | + @"style":@"1", | ||
| 77 | @"title":@"隐私", | 84 | @"title":@"隐私", |
| 78 | @"height":@"51", | 85 | @"height":@"51", |
| 79 | @"lineHeight":@"1" | 86 | @"lineHeight":@"1" |
| @@ -200,14 +207,18 @@ static const NSInteger timeValue = 1.5; | @@ -200,14 +207,18 @@ static const NSInteger timeValue = 1.5; | ||
| 200 | CNLiveFontSettingController *vc = [[CNLiveFontSettingController alloc]init]; | 207 | CNLiveFontSettingController *vc = [[CNLiveFontSettingController alloc]init]; |
| 201 | [self.navigationController pushViewController:vc animated:YES]; | 208 | [self.navigationController pushViewController:vc animated:YES]; |
| 202 | } | 209 | } |
| 203 | - else if(indexPath.row == 5){ // 隐私 | 210 | + else if(indexPath.row == 5){ // 设置聊天背景图片 |
| 211 | + CNLiveBackgroundImageController *vc = [[CNLiveBackgroundImageController alloc]init]; | ||
| 212 | + [self.navigationController pushViewController:vc animated:YES]; | ||
| 213 | + } | ||
| 214 | + else if(indexPath.row == 6){ // 隐私 | ||
| 204 | CNLivePrivacyController *vc = [[CNLivePrivacyController alloc]init]; | 215 | CNLivePrivacyController *vc = [[CNLivePrivacyController alloc]init]; |
| 205 | [self.navigationController pushViewController:vc animated:YES]; | 216 | [self.navigationController pushViewController:vc animated:YES]; |
| 206 | } | 217 | } |
| 207 | - else if(indexPath.row == 6){ //音量开关 | 218 | + else if(indexPath.row == 7){ //音量开关 |
| 208 | 219 | ||
| 209 | } | 220 | } |
| 210 | - else if(indexPath.row == 7){ // 清除缓存 | 221 | + else if(indexPath.row == 8){ // 清除缓存 |
| 211 | __weak typeof(self) weakSelf = self; | 222 | __weak typeof(self) weakSelf = self; |
| 212 | QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"确定" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | 223 | QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"确定" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { |
| 213 | __strong typeof(weakSelf) strongSelf = weakSelf; | 224 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| @@ -238,11 +249,11 @@ static const NSInteger timeValue = 1.5; | @@ -238,11 +249,11 @@ static const NSInteger timeValue = 1.5; | ||
| 238 | 249 | ||
| 239 | [alertController showWithAnimated:YES]; | 250 | [alertController showWithAnimated:YES]; |
| 240 | 251 | ||
| 241 | - }else if (indexPath.row == 8){ | 252 | + }else if (indexPath.row == 9){ |
| 242 | CNLiveAboutUsController *vc = [[CNLiveAboutUsController alloc]init]; | 253 | CNLiveAboutUsController *vc = [[CNLiveAboutUsController alloc]init]; |
| 243 | [self.navigationController pushViewController:vc animated:YES]; | 254 | [self.navigationController pushViewController:vc animated:YES]; |
| 244 | } | 255 | } |
| 245 | - else if (indexPath.row == 9) { | 256 | + else if (indexPath.row == 10) { |
| 246 | CNLiveCancellationController *vc = [[CNLiveCancellationController alloc]init]; | 257 | CNLiveCancellationController *vc = [[CNLiveCancellationController alloc]init]; |
| 247 | [self.navigationController pushViewController:vc animated:YES]; | 258 | [self.navigationController pushViewController:vc animated:YES]; |
| 248 | } | 259 | } |
Example/CNLiveSettingModule.xcodeproj/project.pbxproj
| @@ -208,6 +208,7 @@ | @@ -208,6 +208,7 @@ | ||
| 208 | 6003F587195388D20070C39A /* Frameworks */, | 208 | 6003F587195388D20070C39A /* Frameworks */, |
| 209 | 6003F588195388D20070C39A /* Resources */, | 209 | 6003F588195388D20070C39A /* Resources */, |
| 210 | 6D9A35784F56B3BE6F09B722 /* [CP] Embed Pods Frameworks */, | 210 | 6D9A35784F56B3BE6F09B722 /* [CP] Embed Pods Frameworks */, |
| 211 | + 265B673AE18D46E894A61EF4 /* [CP] Copy Pods Resources */, | ||
| 211 | ); | 212 | ); |
| 212 | buildRules = ( | 213 | buildRules = ( |
| 213 | ); | 214 | ); |
| @@ -298,6 +299,24 @@ | @@ -298,6 +299,24 @@ | ||
| 298 | /* End PBXResourcesBuildPhase section */ | 299 | /* End PBXResourcesBuildPhase section */ |
| 299 | 300 | ||
| 300 | /* Begin PBXShellScriptBuildPhase section */ | 301 | /* Begin PBXShellScriptBuildPhase section */ |
| 302 | + 265B673AE18D46E894A61EF4 /* [CP] Copy Pods Resources */ = { | ||
| 303 | + isa = PBXShellScriptBuildPhase; | ||
| 304 | + buildActionMask = 2147483647; | ||
| 305 | + files = ( | ||
| 306 | + ); | ||
| 307 | + inputPaths = ( | ||
| 308 | + "${PODS_ROOT}/Target Support Files/Pods-CNLiveSettingModule_Example/Pods-CNLiveSettingModule_Example-resources.sh", | ||
| 309 | + "${PODS_CONFIGURATION_BUILD_DIR}/CNLiveSettingModule/CNLiveSettingModule.bundle", | ||
| 310 | + ); | ||
| 311 | + name = "[CP] Copy Pods Resources"; | ||
| 312 | + outputPaths = ( | ||
| 313 | + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CNLiveSettingModule.bundle", | ||
| 314 | + ); | ||
| 315 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 316 | + shellPath = /bin/sh; | ||
| 317 | + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveSettingModule_Example/Pods-CNLiveSettingModule_Example-resources.sh\"\n"; | ||
| 318 | + showEnvVarsInLog = 0; | ||
| 319 | + }; | ||
| 301 | 653FED99FAD33AD7306D3799 /* [CP] Check Pods Manifest.lock */ = { | 320 | 653FED99FAD33AD7306D3799 /* [CP] Check Pods Manifest.lock */ = { |
| 302 | isa = PBXShellScriptBuildPhase; | 321 | isa = PBXShellScriptBuildPhase; |
| 303 | buildActionMask = 2147483647; | 322 | buildActionMask = 2147483647; |
| @@ -328,34 +347,50 @@ | @@ -328,34 +347,50 @@ | ||
| 328 | inputPaths = ( | 347 | inputPaths = ( |
| 329 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveSettingModule_Example/Pods-CNLiveSettingModule_Example-frameworks.sh", | 348 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveSettingModule_Example/Pods-CNLiveSettingModule_Example-frameworks.sh", |
| 330 | "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", | 349 | "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", |
| 350 | + "${BUILT_PRODUCTS_DIR}/CNLiveAVCamera/CNLiveAVCamera.framework", | ||
| 331 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", | 351 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", |
| 352 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework", | ||
| 332 | "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework", | 353 | "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework", |
| 354 | + "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework", | ||
| 355 | + "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework", | ||
| 333 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", | 356 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", |
| 357 | + "${BUILT_PRODUCTS_DIR}/CNLiveImagePickerController/CNLiveImagePickerController.framework", | ||
| 334 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", | 358 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", |
| 335 | - "${BUILT_PRODUCTS_DIR}/CNLiveSettingModule/CNLiveSettingModule.framework", | ||
| 336 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", | 359 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", |
| 360 | + "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework", | ||
| 337 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", | 361 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", |
| 338 | "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", | 362 | "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", |
| 363 | + "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework", | ||
| 339 | "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", | 364 | "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", |
| 340 | "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", | 365 | "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", |
| 341 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", | 366 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", |
| 367 | + "${BUILT_PRODUCTS_DIR}/Qiniu/Qiniu.framework", | ||
| 368 | + "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework", | ||
| 342 | "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", | 369 | "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", |
| 343 | "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", | 370 | "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", |
| 344 | ); | 371 | ); |
| 345 | name = "[CP] Embed Pods Frameworks"; | 372 | name = "[CP] Embed Pods Frameworks"; |
| 346 | outputPaths = ( | 373 | outputPaths = ( |
| 347 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", | 374 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", |
| 375 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveAVCamera.framework", | ||
| 348 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", | 376 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", |
| 377 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework", | ||
| 349 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework", | 378 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework", |
| 379 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework", | ||
| 380 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework", | ||
| 350 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", | 381 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", |
| 382 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveImagePickerController.framework", | ||
| 351 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", | 383 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", |
| 352 | - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveSettingModule.framework", | ||
| 353 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", | 384 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", |
| 385 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework", | ||
| 354 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", | 386 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", |
| 355 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", | 387 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", |
| 388 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework", | ||
| 356 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", | 389 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", |
| 357 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", | 390 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", |
| 358 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", | 391 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", |
| 392 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Qiniu.framework", | ||
| 393 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDAutoLayout.framework", | ||
| 359 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", | 394 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", |
| 360 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", | 395 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", |
| 361 | ); | 396 | ); |
Example/CNLiveSettingModule/CNLiveSettingModule-Info.plist
| @@ -2,6 +2,14 @@ | @@ -2,6 +2,14 @@ | ||
| 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 3 | <plist version="1.0"> | 3 | <plist version="1.0"> |
| 4 | <dict> | 4 | <dict> |
| 5 | + <key>NSCameraUsageDescription</key> | ||
| 6 | + <string>App需要您的同意,才能访问相机</string> | ||
| 7 | + <key>NSMicrophoneUsageDescription</key> | ||
| 8 | + <string>App需要您的同意,才能访问麦克风</string> | ||
| 9 | + <key>NSPhotoLibraryAddUsageDescription</key> | ||
| 10 | + <string>App需要您的同意,才能访问相册</string> | ||
| 11 | + <key>NSPhotoLibraryUsageDescription</key> | ||
| 12 | + <string>App需要您的同意,才能访问相册</string> | ||
| 5 | <key>NSAppTransportSecurity</key> | 13 | <key>NSAppTransportSecurity</key> |
| 6 | <dict> | 14 | <dict> |
| 7 | <key>NSAllowsArbitraryLoads</key> | 15 | <key>NSAllowsArbitraryLoads</key> |
Example/Podfile
| @@ -7,6 +7,10 @@ platform :ios, '9.0' | @@ -7,6 +7,10 @@ platform :ios, '9.0' | ||
| 7 | target 'CNLiveSettingModule_Example' do | 7 | target 'CNLiveSettingModule_Example' do |
| 8 | pod 'CNLiveSettingModule', :path => '../' | 8 | pod 'CNLiveSettingModule', :path => '../' |
| 9 | 9 | ||
| 10 | + #依赖三方私有库,如果里面有.a的时候加上这个 | ||
| 11 | + pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} | ||
| 12 | + end | ||
| 13 | + | ||
| 10 | target 'CNLiveSettingModule_Tests' do | 14 | target 'CNLiveSettingModule_Tests' do |
| 11 | inherit! :search_paths | 15 | inherit! :search_paths |
| 12 | 16 |