XYStartVoiceLiveViewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. //
  2. // XYStartVoiceLiveViewController.m
  3. // Timi
  4. //
  5. // Created by 翟玉磊 on 2021/10/25.
  6. //
  7. #import "XYStartVoiceLiveViewController.h"
  8. #import "XYStartVoiceLiveViewModel.h"
  9. #import "XYVoiceLiveRecordViewController.h"
  10. @interface XYStartVoiceLiveViewController ()<UITextViewDelegate, SelectImageHandlerDelegate>
  11. @property (nonatomic, strong) XYStartVoiceLiveViewModel *viewModel;
  12. @property (nonatomic, strong) UIView *customNavigationView;
  13. @property (nonatomic, strong) UIButton *backButton;
  14. @property (nonatomic, strong) UILabel *titleLabel;
  15. @property (nonatomic, strong) UIButton *rightButton;
  16. @property (nonatomic, strong) UIView *infoView;
  17. @property (nonatomic, strong) UIImageView *coverImageView;
  18. @property (nonatomic, strong) UILabel *coverTipLabel;
  19. @property (nonatomic, strong) UILabel *tipLabel;
  20. @property (nonatomic, strong) PlaceholderTextView *titleTextView;
  21. @property (nonatomic, strong) UIView *line;
  22. @property (nonatomic, strong) UILabel *familyNameLabel;
  23. @property (nonatomic, strong) UIButton *categoryButton;
  24. @property (nonatomic, strong) UIButton *starLiveButton;
  25. @property (nonatomic, strong) UIButton *agreementBoxButton;
  26. @property (nonatomic, strong) UILabel *agreementLabel;
  27. @property (nonatomic, strong) SelectImageHandler *selectImageHandler;
  28. @end
  29. @implementation XYStartVoiceLiveViewController
  30. - (instancetype)init
  31. {
  32. self = [super init];
  33. if (self) {
  34. self.prefersNavigationBarHidden = YES;
  35. }
  36. return self;
  37. }
  38. #pragma mark - Override
  39. - (void)bindViewModel {
  40. self.viewModel = [XYStartVoiceLiveViewModel new];
  41. }
  42. - (void)requestRemoteData {
  43. [self.viewModel getInitValueRequestCompleted:^(NSError * _Nonnull error) {
  44. if (error) {
  45. [SVProgressHUD showInfoWithStatus:error.domain];
  46. return;
  47. }
  48. [self updateView];
  49. }];
  50. }
  51. - (void)viewDidLoad {
  52. [super viewDidLoad];
  53. // Do any additional setup after loading the view.
  54. self.title = @"开播";
  55. [self setupUI];
  56. }
  57. - (void)setupUI {
  58. self.view.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT) direction:GradientChangeDirectionVertical colors:@[ColorFromHexString(@"#A988E5"), ColorFromHexString(@"#7F71DD"), ColorFromHexString(@"#3E4FD2")]];
  59. // 导航设置
  60. [self setupNavationView];
  61. [self.view addSubview:self.infoView];
  62. [self.infoView addSubview:self.coverImageView];
  63. [self.infoView addSubview:self.coverTipLabel];
  64. [self.infoView addSubview:self.tipLabel];
  65. [self.infoView addSubview:self.titleTextView];
  66. [self.infoView addSubview:self.line];
  67. [self.infoView addSubview:self.familyNameLabel];
  68. [self.infoView addSubview:self.categoryButton];
  69. [self.view addSubview:self.starLiveButton];
  70. [self.view addSubview:self.agreementBoxButton];
  71. [self.view addSubview:self.agreementLabel];
  72. // [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  73. // make.top.equalTo(self.view).offset(8.0f + NAVGATION_HEIGHT);
  74. // make.left.equalTo(self.view).offset(16.0f);
  75. // make.right.equalTo(self.view).offset(-16.0f);
  76. // make.height.equalTo(@120.0f);
  77. // }];
  78. [self.coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.left.equalTo(self.infoView).offset(8.0f);
  80. make.centerY.equalTo(self.infoView);
  81. make.width.height.equalTo(@104.0f);
  82. }];
  83. [self.coverTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.left.right.bottom.equalTo(self.coverImageView);
  85. make.height.equalTo(@18.0f);
  86. }];
  87. [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.equalTo(self.coverImageView.mas_right).offset(8.0f);
  89. make.top.equalTo(self.infoView).offset(8.0f);
  90. make.width.equalTo(@138.0f);
  91. make.height.equalTo(@18.0f);
  92. }];
  93. // [self.titleTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  94. // make.left.equalTo(self.coverImageView.mas_right).offset(8.0f);
  95. // make.right.equalTo(self.infoView.mas_right).offset(-8.0f);
  96. // make.top.equalTo(self.tipLabel.mas_bottom).offset(8.0f);
  97. // make.height.equalTo(@44.0f);
  98. // }];
  99. [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.left.equalTo(self.coverImageView.mas_right).offset(8.0f);
  101. make.right.equalTo(self.infoView.mas_right).offset(-8.0f);
  102. make.bottom.equalTo(self.infoView.mas_bottom).offset(-33.0f);
  103. make.height.equalTo(@1.0f);
  104. }];
  105. [self.familyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.equalTo(self.coverImageView.mas_right).offset(8.0f);
  107. make.top.equalTo(self.line.mas_bottom).offset(8.0f);
  108. make.height.equalTo(@17.0f);
  109. }];
  110. [self.categoryButton mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.left.equalTo(self.familyNameLabel.mas_right).offset(8.0f);
  112. make.top.equalTo(self.line.mas_bottom);
  113. make.bottom.equalTo(self.infoView);
  114. make.width.equalTo(@38.0f);
  115. }];
  116. [self.starLiveButton mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.left.equalTo(self.view).offset(28.0f);
  118. make.right.equalTo(self.view).offset(-28.0f);
  119. make.bottom.equalTo(self.view).offset(-(HOME_INDICATOR_HEIGHT+90.0f));
  120. make.height.equalTo(@48.0f);
  121. }];
  122. [self.agreementLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  123. make.centerX.equalTo(self.view);
  124. make.top.equalTo(self.starLiveButton.mas_bottom).offset(16.0f);
  125. make.width.equalTo(@225.0f);
  126. make.height.equalTo(@17.0f);
  127. }];
  128. [self.agreementBoxButton mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.right.equalTo(self.agreementLabel.mas_left).offset(-4.0f);
  130. make.centerY.equalTo(self.agreementLabel);
  131. make.width.height.equalTo(@20.0f);
  132. }];
  133. [self.infoView addViewBorder:Color_Clear redian:4];
  134. [self.coverImageView addViewBorder:Color_Clear redian:4];
  135. [self.starLiveButton addViewBorder:Color_Clear redian:48/2];
  136. }
  137. - (void)setupNavationView {
  138. [self.view addSubview:self.customNavigationView];
  139. [self.customNavigationView addSubview:self.backButton];
  140. [self.customNavigationView addSubview:self.titleLabel];
  141. [self.customNavigationView addSubview:self.rightButton];
  142. [self.customNavigationView mas_makeConstraints:^(MASConstraintMaker *make) {
  143. make.left.top.right.equalTo(self.view);
  144. make.height.equalTo(@(NAVGATION_HEIGHT));
  145. }];
  146. [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.left.equalTo(self.customNavigationView).offset(5.0f);
  148. make.bottom.equalTo(self.customNavigationView);
  149. make.width.height.equalTo(@44.0f);
  150. }];
  151. [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.right.equalTo(self.customNavigationView).offset(-5.0f);
  153. make.bottom.equalTo(self.customNavigationView);
  154. make.height.equalTo(@44.0f);
  155. make.width.equalTo(@70.0f);
  156. }];
  157. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.bottom.left.right.equalTo(self.customNavigationView);
  159. make.height.equalTo(@44.0f);
  160. }];
  161. }
  162. - (void)updateView {
  163. if (self.viewModel.passType != 1) {
  164. NSString *text = @"";
  165. switch (self.viewModel.passType) {
  166. case 2:
  167. text = @"手机号不通过";
  168. break;
  169. case 3:
  170. text = @"实名不通过";
  171. break;
  172. case 4:
  173. text = @"加入家族不通过";
  174. break;
  175. case 5:
  176. text = @"其他原因不通过";
  177. break;
  178. default:
  179. break;
  180. }
  181. [SVProgressHUD showInfoWithStatus:text];
  182. return;
  183. }
  184. // 封面
  185. if (StringIsNotEmpty(self.viewModel.liveInfoModel.roomCover)) {
  186. [self.coverImageView sd_setImageWithURL:UrlForString(self.viewModel.liveInfoModel.roomCover) placeholderImage:placeholderImage()];
  187. }else {
  188. [self.coverImageView sd_setImageWithURL:UrlForString([XYUserInfoManager nowUser].userAvatar) placeholderImage:placeholderImage() completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  189. if (image) {
  190. self.viewModel.coverImage = image;
  191. }
  192. }];
  193. }
  194. // 标题
  195. if (StringIsNotEmpty(self.viewModel.liveInfoModel.roomName)) {
  196. self.titleTextView.text = self.viewModel.liveInfoModel.roomName;
  197. }
  198. // 家族
  199. if (StringIsNotEmpty(self.viewModel.liveInfoModel.familyName)) {
  200. self.familyNameLabel.text = self.viewModel.liveInfoModel.familyName;
  201. }
  202. // 房间标签
  203. [self updateCategoryData:self.viewModel.selectedTagModel];
  204. }
  205. /// 设置房间类别
  206. - (void)updateCategoryData:(XYVoiceRoomTagModel *)model {
  207. self.viewModel.selectedTagModel = model;
  208. [self.categoryButton setTitle:model.categoryName forState:UIControlStateNormal];
  209. [self.categoryButton setImage:ImageNamed(@"white_rightarrow") forState:UIControlStateNormal];
  210. CGFloat buttonWidth = [self.categoryButton.titleLabel sizeThatFits:CGSizeMake(MAXFLOAT, 17.0f)].width;
  211. buttonWidth += (2.0f + 12.0f);
  212. [self.categoryButton mas_updateConstraints:^(MASConstraintMaker *make) {
  213. make.width.equalTo(@(buttonWidth));
  214. }];
  215. // 整条图片和文字位置
  216. [self.categoryButton buttonDistance:2 direction:right];
  217. }
  218. #pragma mark - Action
  219. - (void)backAction:(id)sender {
  220. [self.navigationController popViewControllerAnimated:YES];
  221. }
  222. - (void)rightItemAction:(id)sender {
  223. [self.navigationController pushViewController:XYVoiceLiveRecordViewController.new animated:YES];
  224. }
  225. /// 选择图片
  226. - (void)selectedCoverTapAction:(id)sedner {
  227. self.selectImageHandler.allowSquareCrop = NO;
  228. self.selectImageHandler.allowHorizontalCrop = NO;
  229. [self.selectImageHandler showImagePickerControllerWithMaxCount:1 parentController:self];
  230. }
  231. /// 选择直播房间类别
  232. - (void)selectedLiveRoomCategoryAction:(id)sender {
  233. NSMutableArray *categoryNames = [NSMutableArray array];
  234. for (XYVoiceRoomTagModel *categoryModel in self.viewModel.voiceRoomCategoryModels) {
  235. [categoryNames addObject:categoryModel.categoryName];
  236. }
  237. if (categoryNames.count == 0) {
  238. return;
  239. }
  240. WeakSelf
  241. BasePickerViewController *tagPicker = [[BasePickerViewController alloc] initWithTitle:@"房间标签" dataArray:categoryNames target:self sureBlock:^(NSInteger index, id _Nonnull info) {
  242. NSLog(@"tagPicker:%@ 索引:%ld", info, (long)index);
  243. XYVoiceRoomTagModel *model = [self.viewModel.voiceRoomCategoryModels objectAtIndex:index];
  244. [weakSelf updateCategoryData:model];
  245. }];
  246. [tagPicker show];
  247. }
  248. /// 开始直播
  249. - (void)starLiveButtonAction:(id)sender {
  250. // 同意协议
  251. if (!self.agreementBoxButton.selected) {
  252. [SVProgressHUD showInfoWithStatus:@"请先同意协议"];
  253. return;
  254. }
  255. // 房间标题
  256. if (StringIsEmpty(self.viewModel.liveInfoModel.roomName)) {
  257. [SVProgressHUD showInfoWithStatus:@"请输入房间标题"];
  258. return;
  259. }
  260. // 房间类型必须选择
  261. if (self.viewModel.selectedTagModel == nil) {
  262. [SVProgressHUD showInfoWithStatus:@"请选择房间类型"];
  263. return;
  264. }
  265. WeakSelf
  266. if (self.viewModel.coverImage) {
  267. [SVProgressHUD showWithStatus:@"上传中..."];
  268. [self.viewModel uploadCoverImageCompleted:^(NSError * _Nonnull error) {
  269. if (error) {
  270. [SVProgressHUD showInfoWithStatus:error.domain];
  271. return;
  272. }
  273. [SVProgressHUD showWithStatus:@"开播中..."];
  274. [self.viewModel startLiveCompleted:^(NSError * _Nonnull error) {
  275. if (error) {
  276. [SVProgressHUD showInfoWithStatus:error.domain];
  277. return;
  278. }
  279. [SVProgressHUD dismiss];
  280. // 进入直播间
  281. [[XYChatRoomManager sharedInstance] showChatRoomWithRoomId:self.viewModel.liveInfoModel.roomId roomCoverUrl:self.viewModel.liveInfoModel.roomCover completion:^{
  282. // 刷新info
  283. [weakSelf requestRemoteData];
  284. }];
  285. }];
  286. }];
  287. }else {
  288. [SVProgressHUD show];
  289. [self.viewModel startLiveCompleted:^(NSError * _Nonnull error) {
  290. if (error) {
  291. [SVProgressHUD showInfoWithStatus:error.domain];
  292. return;
  293. }
  294. [SVProgressHUD dismiss];
  295. // 进入直播间
  296. [[XYChatRoomManager sharedInstance] showChatRoomWithRoomId:self.viewModel.liveInfoModel.roomId roomCoverUrl:self.viewModel.liveInfoModel.roomCover completion:^{
  297. // 刷新info
  298. [weakSelf requestRemoteData];
  299. }];
  300. }];
  301. }
  302. }
  303. /// 同意协议
  304. - (void)agreementBoxButtonAction:(UIButton *)sender {
  305. sender.selected = !sender.selected;
  306. }
  307. /// 查看协议
  308. - (void)lookAgreementActionWithAgreementName:(NSString *)name {
  309. BaseWebViewController *controller = [BaseWebViewController new];
  310. controller.requestUrl = App_User_Url;
  311. controller.title = name;
  312. [self.navigationController pushViewController:controller animated:YES];
  313. }
  314. #pragma mark - UITextViewDelegate
  315. - (void)textViewDidChange:(UITextView *)textView {
  316. self.viewModel.liveInfoModel.roomName = textView.text;
  317. }
  318. - (void)textViewDidEndEditing:(UITextView *)textView {
  319. // 结束编辑
  320. self.viewModel.liveInfoModel.roomName = textView.text;
  321. }
  322. #pragma mark - SelectImageHandlerDelegate
  323. - (void)didFinishPickingPhotos:(NSArray<UIImage *>*)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto {
  324. if (photos.count == 0) {
  325. return;
  326. }
  327. UIImage *image = [photos firstObject];
  328. self.coverImageView.image = self.viewModel.coverImage = image;
  329. }
  330. #pragma mark - 懒加载
  331. - (UIView *)customNavigationView {
  332. if (_customNavigationView == nil) {
  333. _customNavigationView = [[UIView alloc] init];
  334. _customNavigationView.backgroundColor = Color_Clear;
  335. }
  336. return _customNavigationView;
  337. }
  338. - (UIButton *)backButton {
  339. if (_backButton == nil) {
  340. _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
  341. [_backButton setImage:ImageNamed(@"icon_back_bai") forState:UIControlStateNormal];
  342. [_backButton addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
  343. }
  344. return _backButton;
  345. }
  346. - (UILabel *)titleLabel {
  347. if (_titleLabel == nil) {
  348. _titleLabel = [UILabel createLabelTextColor:Color_White fount:Font_B(16)];
  349. _titleLabel.textAlignment = NSTextAlignmentCenter;
  350. _titleLabel.text = @"开播";
  351. }
  352. return _titleLabel;
  353. }
  354. - (UIButton *)rightButton {
  355. if (_rightButton == nil) {
  356. _rightButton = [UIButton createButtonTextColor:Color_White textFont:Font(16)];
  357. [_rightButton setTitle:@"开播记录" forState:UIControlStateNormal];
  358. [_rightButton addTarget:self action:@selector(rightItemAction:) forControlEvents:UIControlEventTouchUpInside];
  359. }
  360. return _rightButton;
  361. }
  362. - (UIView *)infoView {
  363. if (_infoView == nil) {
  364. _infoView = [[UIView alloc] initWithFrame:CGRectMake(16.0f, NAVGATION_HEIGHT+8.0f, SCREEN_WIDTH - 16.0f * 2, 120.0f)];
  365. _infoView.backgroundColor = ColorFromHexStringWithAlpha(@"#000000", 0.35f);
  366. }
  367. return _infoView;
  368. }
  369. - (UIImageView *)coverImageView {
  370. if (_coverImageView == nil) {
  371. _coverImageView = [UIImageView new];
  372. _coverImageView.clipsToBounds = YES;
  373. _coverImageView.contentMode = UIViewContentModeScaleAspectFill;
  374. // 添加点击事件
  375. _coverImageView.userInteractionEnabled = YES;
  376. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectedCoverTapAction:)];
  377. [_coverImageView addGestureRecognizer:tap];
  378. }
  379. return _coverImageView;
  380. }
  381. - (UILabel *)coverTipLabel {
  382. if (_coverTipLabel == nil) {
  383. _coverTipLabel = [UILabel createLabelTextColor:Color_White fount:Font(12)];
  384. _coverTipLabel.text = @"点击更换封面";
  385. _coverTipLabel.textAlignment = NSTextAlignmentCenter;
  386. _coverTipLabel.backgroundColor = ColorFromHexStringWithAlpha(@"#000000", 0.35f);
  387. }
  388. return _coverTipLabel;
  389. }
  390. - (UILabel *)tipLabel {
  391. if (_tipLabel == nil) {
  392. _tipLabel = [UILabel createLabelTextColor:ColorFromHexString(@"#E89C38") fount:Font(10)];
  393. _tipLabel.backgroundColor = ColorFromHexStringWithAlpha(@"#E89C38", 0.1f);
  394. _tipLabel.text = @"优质的封面和标题更吸引用户";
  395. _tipLabel.textAlignment = NSTextAlignmentCenter;
  396. }
  397. return _tipLabel;
  398. }
  399. - (PlaceholderTextView *)titleTextView {
  400. if (_titleTextView == nil) {
  401. _titleTextView = [[PlaceholderTextView alloc] initWithFrame:CGRectMake(120.0f, 34.0f, SCREEN_WIDTH - 16.0f - 120.0f - 8.0f - 16.0f, 50.0f)];
  402. _titleTextView.font = Font(16);
  403. _titleTextView.textColor = Color_White;
  404. _titleTextView.placeholder = @"设置一个标题吧~";
  405. _titleTextView.placeholderTextColor = Color_White;
  406. _titleTextView.delegate = self;
  407. _titleTextView.contentInset = UIEdgeInsetsMake(-8.f, 0.f, -8.f, 0.f);
  408. _titleTextView.backgroundColor = Color_Clear;
  409. }
  410. return _titleTextView;
  411. }
  412. - (UIView *)line {
  413. if (_line == nil) {
  414. _line = [UIView new];
  415. _line.backgroundColor = ColorFromHexStringWithAlpha(@"#FFFFFF", 0.05f);
  416. }
  417. return _line;
  418. }
  419. - (UILabel *)familyNameLabel {
  420. if (_familyNameLabel == nil) {
  421. _familyNameLabel = [UILabel createLabelTextColor:Color_White fount:Font(12)];
  422. }
  423. return _familyNameLabel;
  424. }
  425. - (UIButton *)categoryButton {
  426. if (_categoryButton == nil) {
  427. _categoryButton = [UIButton createButtonTextColor:Color_White textFont:Font(12)];
  428. [_categoryButton addTarget:self action:@selector(selectedLiveRoomCategoryAction:) forControlEvents:UIControlEventTouchUpInside];
  429. }
  430. return _categoryButton;
  431. }
  432. - (UIButton *)starLiveButton {
  433. if (_starLiveButton == nil) {
  434. _starLiveButton = [UIButton createButtonTextColor:Color_White textFont:Font(16)];
  435. [_starLiveButton setTitle:@"开始直播" forState:UIControlStateNormal];
  436. _starLiveButton.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(SCREEN_WIDTH - 28.0f * 2, 48.0f) direction:GradientChangeDirectionLevel startColor:ColorFromHexString(@"#FF3355") endColor:ColorFromHexString(@"#FF808A")];
  437. [_starLiveButton addTarget:self action:@selector(starLiveButtonAction:) forControlEvents:UIControlEventTouchUpInside];
  438. }
  439. return _starLiveButton;
  440. }
  441. - (UIButton *)agreementBoxButton {
  442. if (_agreementBoxButton == nil) {
  443. _agreementBoxButton = [UIButton buttonWithType:UIButtonTypeCustom];
  444. [_agreementBoxButton setImage:ImageNamed(@"xy_live_agreement_unselected") forState:UIControlStateNormal];
  445. [_agreementBoxButton setImage:ImageNamed(@"xy_live_agreement_selected") forState:UIControlStateSelected];
  446. _agreementBoxButton.selected = YES;
  447. [_agreementBoxButton addTarget:self action:@selector(agreementBoxButtonAction:) forControlEvents:UIControlEventTouchUpInside];
  448. }
  449. return _agreementBoxButton;
  450. }
  451. - (UILabel *)agreementLabel {
  452. if (_agreementLabel == nil) {
  453. _agreementLabel = [UILabel createLabelTextColor:Color_White fount:Font(12)];
  454. _agreementLabel.textAlignment = NSTextAlignmentCenter;
  455. NSString *agreementName = @"《用户协议&免责声明》";
  456. NSString *content = [NSString stringWithFormat:@"我已经阅读并同意%@", agreementName];
  457. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:content];
  458. // 设置字体颜色
  459. [attributedString addAttribute:NSForegroundColorAttributeName value:Color_White range:NSMakeRange(0, content.length)];
  460. // 设置字体
  461. [attributedString addAttribute:NSFontAttributeName value:Font(12) range:NSMakeRange(0, content.length)];
  462. // 下划线
  463. [attributedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(content.length-agreementName.length+1, agreementName.length-2)];
  464. _agreementLabel.attributedText = attributedString;
  465. WeakSelf
  466. [_agreementLabel yb_addAttributeTapActionWithStrings:@[agreementName] tapClicked:^(NSString *string, NSRange range, NSInteger index) {
  467. [weakSelf lookAgreementActionWithAgreementName:agreementName];
  468. }];
  469. // 点击效果关闭
  470. _agreementLabel.enabledTapEffect = NO;
  471. }
  472. return _agreementLabel;
  473. }
  474. - (SelectImageHandler *)selectImageHandler {
  475. if (!_selectImageHandler) {
  476. _selectImageHandler = [[SelectImageHandler alloc] init];
  477. _selectImageHandler.delegate = self;
  478. _selectImageHandler.maxImagesCount = 1;
  479. }
  480. return _selectImageHandler;
  481. }
  482. /*
  483. #pragma mark - Navigation
  484. // In a storyboard-based application, you will often want to do a little preparation before navigation
  485. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  486. // Get the new view controller using [segue destinationViewController].
  487. // Pass the selected object to the new view controller.
  488. }
  489. */
  490. @end