PanoramaGuideView.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. //
  2. // PanoramaGuideView.m
  3. // LenzCameraNativeModuleForRN
  4. //
  5. // Created by 王昭威 on 2023/1/25.
  6. //
  7. #import "PanoramaGuideView.h"
  8. #import <YYText/NSAttributedString+YYText.h>
  9. #import <AVFoundation/AVFoundation.h>
  10. #import <YYText/YYLabel.h>
  11. #import <MetalKit/MetalKit.h>
  12. #import "Renderer.h"
  13. #import "LenzHeader.h"
  14. CGFloat const PanoramaGuideViewWOrH = 120;
  15. @interface PanoramaGuideViewPreviewContainer : MTKView
  16. @end
  17. @implementation PanoramaGuideViewPreviewContainer
  18. @end
  19. @interface PanoramaGuideView() <MTKViewDelegate>
  20. @property (nonatomic, strong) PanoramaGuideViewPreviewContainer* container;
  21. @property (nonatomic, assign) CGFloat aspect;
  22. @property (nonatomic, assign) CGFloat offset;
  23. @property (nonatomic, strong) NSTimer* timer;
  24. @property (nonatomic, strong) UIImageView *whiteArrow;
  25. @property (nonatomic, strong) UIView* line;
  26. @property (nonatomic, weak) UIView* superV;
  27. @property (nonatomic, strong)YYLabel *label;
  28. @property (nonatomic) UIImageView *showImageView;
  29. @property (nonatomic) PanoramaArrowDir lastArrowDir;
  30. @property (nonatomic) NSNumber *offSetTop;
  31. @property (nonatomic) NSNumber *offSetLeft;
  32. @property (nonatomic) PanoramaOrientationViewDirectionEnum currentDirection;
  33. @end
  34. @implementation PanoramaGuideView
  35. - (instancetype)init{
  36. self = [super init];
  37. self.backgroundColor = [UIColor jk_colorWithHexString:@"#000000" andAlpha:0.5];
  38. [self addSubview:self.showImageView];
  39. self.offSetTop = @((120-38)/2);
  40. self.offSetLeft = @((120-38)/2);
  41. return self;
  42. }
  43. - (void)willMoveToSuperview:(nullable UIView *)newSuperview;{
  44. [super willMoveToSuperview:newSuperview];
  45. self.superV = newSuperview;
  46. }
  47. - (void)updatePreviewAspect:(CGFloat)aspect{
  48. if(aspect > 0.01){
  49. self.aspect = 1.0 / aspect;
  50. }
  51. else{
  52. self.aspect = 1;
  53. }
  54. [self.container mas_remakeConstraints:^(MASConstraintMaker *make) {
  55. make.left.top.equalTo(self).offset(self.offset);
  56. make.height.equalTo(self);
  57. // it means aspect > 0
  58. make.width.equalTo(self.container.mas_height).multipliedBy(self.aspect);
  59. }];
  60. }
  61. - (void)updateOffset:(CGFloat)offset{
  62. self.offset = offset;
  63. [self.container mas_remakeConstraints:^(MASConstraintMaker *make) {
  64. make.left.equalTo(self).offset(self.offset);
  65. make.top.equalTo(self);
  66. make.height.equalTo(self);
  67. make.width.equalTo(self.container.mas_height).multipliedBy(self.aspect);
  68. }];
  69. }
  70. - (void)direction:(PanoramaOrientationViewDirectionEnum)dir{
  71. self.currentDirection = dir;
  72. [self insertSubview:self.line atIndex:0];
  73. self.line.hidden = YES;
  74. // self.label.hidden = YES;
  75. [self.superV addSubview:self.label];
  76. [self addSubview:self.whiteArrow];
  77. [self.line mas_remakeConstraints:^(MASConstraintMaker *make) {
  78. switch (dir) {
  79. case PanoramaOrientationViewLeft:
  80. case PanoramaOrientationViewRight:
  81. {
  82. make.left.right.offset(0);
  83. make.height.offset(0.5);
  84. make.centerY.mas_equalTo(self);
  85. }
  86. break;
  87. case PanoramaOrientationViewUp:
  88. case PanoramaOrientationViewDown:
  89. {
  90. make.top.bottom.offset(0);
  91. make.width.offset(0.5);
  92. make.centerX.mas_equalTo(self);
  93. }
  94. break;
  95. default:
  96. break;
  97. }
  98. }];
  99. // [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  100. // switch (dir) {
  101. // case PanoramaOrientationViewLeft:
  102. // case PanoramaOrientationViewRight: // 横
  103. // {
  104. // make.top.mas_equalTo(self.mas_bottom).offset(5);
  105. // make.centerX.mas_equalTo(self.superV);
  106. // make.height.offset(20);
  107. // make.width.offset(160);
  108. // self.label.verticalForm = NO;
  109. // }
  110. // break;
  111. // case PanoramaOrientationViewUp:
  112. // case PanoramaOrientationViewDown: // 上下
  113. // {
  114. // make.right.mas_equalTo(self.mas_left).offset(-5);
  115. // make.centerY.mas_equalTo(self.superV);
  116. // make.width.offset(20);
  117. // make.height.offset(160);
  118. // self.label.verticalForm = YES;
  119. // }
  120. // break;
  121. //
  122. // default:
  123. // break;
  124. // }
  125. // }];
  126. [self updatePromptLabel];
  127. [self.showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  128. switch (dir) {
  129. case PanoramaOrientationViewUp: {
  130. make.left.right.top.mas_equalTo(0);
  131. make.height.mas_equalTo(0);
  132. make.height.mas_lessThanOrEqualTo(self);
  133. }
  134. break;
  135. case PanoramaOrientationViewDown: {
  136. make.left.right.bottom.mas_equalTo(0);
  137. make.height.mas_equalTo(0);
  138. }
  139. break;
  140. case PanoramaOrientationViewLeft: {
  141. make.left.top.bottom.mas_equalTo(0);
  142. make.width.mas_equalTo(0);
  143. make.width.mas_lessThanOrEqualTo(self);
  144. }
  145. break;
  146. case PanoramaOrientationViewRight: {
  147. make.top.right.bottom.mas_equalTo(0);
  148. make.width.mas_equalTo(0);
  149. make.width.mas_lessThanOrEqualTo(self);
  150. }
  151. break;
  152. default:
  153. break;
  154. }
  155. }];
  156. [UIView animateWithDuration:0.2 animations:^{
  157. __block UIImage *arrow = nil;
  158. /// 白色的箭头
  159. [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
  160. switch (dir) {
  161. case PanoramaOrientationViewLeft: //左
  162. {
  163. make.centerY.mas_equalTo(self);
  164. make.left.offset(0);
  165. arrow = [UIImage loadNamed:@"ai_right_arrow"];
  166. }
  167. break;
  168. case PanoramaOrientationViewRight: // 右
  169. {
  170. make.centerY.mas_equalTo(self);
  171. make.right.offset(0);
  172. arrow = [UIImage loadNamed:@"ai_left_arrow"];
  173. }
  174. break;
  175. case PanoramaOrientationViewUp: //上
  176. {
  177. make.centerX.mas_equalTo(self);
  178. make.top.offset(0);
  179. arrow = [UIImage loadNamed:@"ai_down_arrow"];
  180. }
  181. break;
  182. case PanoramaOrientationViewDown: // 下
  183. {
  184. make.centerX.mas_equalTo(self);
  185. make.bottom.offset(0);
  186. arrow = [UIImage loadNamed:@"ai_up_arrow"];
  187. }
  188. break;
  189. default:
  190. break;
  191. }
  192. }];
  193. self.whiteArrow.image = arrow;
  194. [self setNeedsLayout];
  195. [self layoutIfNeeded];
  196. } completion:^(BOOL finished) {
  197. self.line.hidden = NO;
  198. // self.label.hidden = NO;
  199. }];
  200. }
  201. - (void)updatePromptLabel {
  202. // self.backgroundColor = [UIColor redColor];
  203. // self.superV.backgroundColor = [UIColor yellowColor];
  204. self.label.transform = CGAffineTransformMakeRotation(0);
  205. switch (self.dir) {
  206. case TgDirectionPortrait: {
  207. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  208. switch (self.orginDir) {
  209. case PanoramaOrientationViewLeft:
  210. case PanoramaOrientationViewRight: // 横
  211. {
  212. make.top.mas_equalTo(self.mas_bottom).offset(5);
  213. make.centerX.mas_equalTo(self.superV);
  214. make.height.offset(20);
  215. make.width.offset(160);
  216. self.label.verticalForm = NO;
  217. }
  218. break;
  219. case PanoramaOrientationViewUp:
  220. case PanoramaOrientationViewDown: // 上下
  221. {
  222. make.right.mas_equalTo(self.mas_left).offset(-5);
  223. make.centerY.mas_equalTo(self.superV);
  224. make.width.offset(20);
  225. make.height.offset(160);
  226. self.label.verticalForm = YES;
  227. }
  228. break;
  229. default:
  230. break;
  231. }
  232. }];
  233. }
  234. break;
  235. case TgDirectionDown: {
  236. switch (self.orginDir) {
  237. case PanoramaOrientationViewLeft: {
  238. self.label.transform = CGAffineTransformMakeRotation(-M_PI);
  239. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  240. make.bottom.mas_equalTo(self.mas_top).mas_offset(-20);
  241. make.centerX.mas_equalTo(self);
  242. make.height.offset(20);
  243. make.width.offset(160);
  244. self.label.verticalForm = NO;
  245. }];
  246. }
  247. break;
  248. case PanoramaOrientationViewRight: // 横
  249. {
  250. // self.label.transform = CGAffineTransformMakeRotation(0);
  251. self.label.transform = CGAffineTransformMakeRotation(-M_PI/2);
  252. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  253. make.left.mas_equalTo(self.mas_right).offset(-60);
  254. make.centerY.mas_equalTo(self);
  255. make.height.offset(20);
  256. make.width.offset(160);
  257. self.label.verticalForm = NO;
  258. }];
  259. }
  260. break;
  261. case PanoramaOrientationViewUp: {
  262. self.label.transform = CGAffineTransformMakeRotation(M_PI);
  263. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  264. make.right.mas_equalTo(self.mas_left).offset(-5);
  265. make.centerY.mas_equalTo(self.superV);
  266. make.width.offset(20);
  267. make.height.offset(160);
  268. self.label.verticalForm = YES;
  269. }];
  270. }
  271. break;
  272. case PanoramaOrientationViewDown: // 上下
  273. {
  274. self.label.transform = CGAffineTransformMakeRotation(M_PI);
  275. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  276. make.right.mas_equalTo(self.mas_left).offset(-5);
  277. make.centerY.mas_equalTo(self.superV);
  278. make.width.offset(20);
  279. make.height.offset(160);
  280. self.label.verticalForm = YES;
  281. }];
  282. }
  283. break;
  284. default:
  285. break;
  286. }
  287. }
  288. break;
  289. case TgDirectionLeft: {
  290. switch (self.orginDir) {
  291. case PanoramaOrientationViewLeft: {
  292. // self.label.transform = CGAffineTransformMakeRotation(0);
  293. self.label.transform = CGAffineTransformMakeRotation(M_PI/2);
  294. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  295. make.right.mas_equalTo(self.mas_left).mas_offset(60);
  296. make.centerY.mas_equalTo(self);
  297. make.height.offset(20);
  298. make.width.offset(160);
  299. self.label.verticalForm = NO;
  300. }];
  301. }
  302. break;
  303. case PanoramaOrientationViewRight: // 横
  304. {
  305. // self.label.transform = CGAffineTransformMakeRotation(0);
  306. self.label.transform = CGAffineTransformMakeRotation(M_PI/2);
  307. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  308. make.right.mas_equalTo(self.mas_left).mas_offset(60);
  309. make.centerY.mas_equalTo(self);
  310. make.height.offset(20);
  311. make.width.offset(160);
  312. self.label.verticalForm = NO;
  313. }];
  314. }
  315. break;
  316. case PanoramaOrientationViewUp:{
  317. self.label.transform = CGAffineTransformMakeRotation(M_PI/2);
  318. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  319. make.top.mas_equalTo(self.mas_bottom).offset(-60);
  320. make.centerX.mas_equalTo(self.superV);
  321. make.width.offset(20);
  322. make.height.offset(160);
  323. self.label.verticalForm = YES;
  324. }];
  325. }
  326. break;
  327. case PanoramaOrientationViewDown: // 上下
  328. {
  329. self.label.transform = CGAffineTransformMakeRotation(M_PI/2);
  330. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  331. make.top.mas_equalTo(self.mas_bottom).offset(-60);
  332. make.centerX.mas_equalTo(self.superV);
  333. make.width.offset(20);
  334. make.height.offset(160);
  335. self.label.verticalForm = YES;
  336. }];
  337. }
  338. break;
  339. default:
  340. break;
  341. }
  342. }
  343. break;
  344. case TgDirectionRight: {
  345. switch (self.orginDir) {
  346. case PanoramaOrientationViewLeft: {
  347. self.label.transform = CGAffineTransformMakeRotation(-M_PI/2);
  348. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  349. make.left.mas_equalTo(self.mas_right).offset(-60);
  350. make.centerY.mas_equalTo(self);
  351. make.height.offset(20);
  352. make.width.offset(160);
  353. self.label.verticalForm = NO;
  354. }];
  355. }
  356. break;
  357. case PanoramaOrientationViewRight: // 横
  358. {
  359. self.label.transform = CGAffineTransformMakeRotation(-M_PI/2);
  360. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  361. make.left.mas_equalTo(self.mas_right).offset(-60);
  362. make.centerY.mas_equalTo(self);
  363. make.height.offset(20);
  364. make.width.offset(160);
  365. self.label.verticalForm = NO;
  366. }];
  367. }
  368. break;
  369. case PanoramaOrientationViewUp:{
  370. self.label.transform = CGAffineTransformMakeRotation(-M_PI/2);
  371. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  372. make.top.mas_equalTo(self.mas_bottom).offset(-60);
  373. make.centerX.mas_equalTo(self.superV);
  374. make.width.offset(20);
  375. make.height.offset(160);
  376. self.label.verticalForm = YES;
  377. }];
  378. }
  379. break;
  380. case PanoramaOrientationViewDown: // 上下
  381. {
  382. self.label.transform = CGAffineTransformMakeRotation(-M_PI/2);
  383. [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
  384. make.top.mas_equalTo(self.mas_bottom).offset(-60);
  385. make.centerX.mas_equalTo(self.superV);
  386. make.width.offset(20);
  387. make.height.offset(160);
  388. self.label.verticalForm = YES;
  389. }];
  390. }
  391. break;
  392. default:
  393. break;
  394. }
  395. }
  396. break;
  397. default:
  398. break;
  399. }
  400. }
  401. - (void)showImageWith:(UIImage * _Nullable)image {
  402. dispatch_async(dispatch_get_main_queue(), ^{
  403. CGFloat imageWH = 0;
  404. if (image) {
  405. if (self.currentDirection == PanoramaOrientationViewDown || self.currentDirection == PanoramaOrientationViewUp) {
  406. imageWH = (PanoramaGuideViewWOrH * image.size.height)/image.size.width;
  407. } else {
  408. imageWH = (PanoramaGuideViewWOrH * image.size.width)/image.size.height;
  409. }
  410. } else {
  411. self.offSetTop = @((120-38)/2);
  412. self.offSetLeft = @((120-38)/2);
  413. }
  414. self.showImageView.image = image;
  415. [UIView animateWithDuration:.15 animations:^{
  416. switch (self.currentDirection) {
  417. case PanoramaOrientationViewDown: {
  418. [self.showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  419. make.height.mas_equalTo(imageWH);
  420. make.height.mas_lessThanOrEqualTo(self);
  421. make.left.right.bottom.mas_equalTo(0);
  422. }];
  423. [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
  424. make.bottom.mas_offset(-imageWH);
  425. make.left.mas_equalTo(self.offSetLeft.doubleValue);
  426. }];
  427. }
  428. break;
  429. case PanoramaOrientationViewUp:{
  430. [self.showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  431. make.left.right.top.mas_equalTo(0);
  432. make.height.mas_equalTo(imageWH);
  433. make.height.mas_lessThanOrEqualTo(self);
  434. }];
  435. [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
  436. make.top.mas_offset(imageWH);
  437. make.left.mas_equalTo(self.offSetLeft.doubleValue);
  438. }];
  439. }
  440. break;
  441. case PanoramaOrientationViewRight: {
  442. [self.showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  443. make.width.mas_equalTo(imageWH);
  444. make.width.mas_lessThanOrEqualTo(self);
  445. make.top.right.bottom.mas_equalTo(0);
  446. }];
  447. [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
  448. make.right.mas_offset(-imageWH);
  449. make.top.mas_equalTo(self.offSetTop.doubleValue);
  450. }];
  451. }
  452. break;
  453. case PanoramaOrientationViewLeft:{
  454. [self.showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  455. make.width.mas_equalTo(imageWH);
  456. make.width.mas_lessThanOrEqualTo(self);
  457. make.left.top.bottom.mas_equalTo(0);
  458. }];
  459. [self.whiteArrow mas_remakeConstraints:^(MASConstraintMaker *make) {
  460. make.left.mas_offset(imageWH);
  461. make.top.mas_equalTo(self.offSetTop.doubleValue);
  462. }];
  463. }
  464. break;
  465. default:
  466. break;
  467. }
  468. [self setNeedsLayout];
  469. [self layoutIfNeeded];
  470. }];
  471. });
  472. }
  473. - (void)updateArrowWith:(PanoramaArrowDir)arrowDir dir:(PanoramaOrientationViewDirectionEnum)dir {
  474. // self.lastArrowDir = arrowDir;
  475. dispatch_async(dispatch_get_main_queue(), ^{
  476. if (!self.showImageView.image) {
  477. return;
  478. }
  479. if (dir == PanoramaOrientationViewDown || dir == PanoramaOrientationViewUp) {
  480. if (arrowDir == PanoramaArrowDirCenter) {
  481. self.offSetLeft = @((120-38)/2);
  482. } else if (arrowDir == PanoramaArrowDirLeft) {
  483. self.offSetLeft = @(0);
  484. } else if (arrowDir == PanoramaArrowDirRight) {
  485. self.offSetLeft = @(120-38);
  486. }
  487. }
  488. else if (dir == PanoramaOrientationViewLeft || dir == PanoramaOrientationViewRight) {
  489. if (arrowDir == PanoramaArrowDirCenter) {
  490. self.offSetTop = @((120-38)/2);
  491. } else if (arrowDir == PanoramaArrowDirUp) {
  492. self.offSetTop = @(0);
  493. } else if (arrowDir == PanoramaArrowDirDown) {
  494. self.offSetTop = @(120-38);
  495. }
  496. }
  497. });
  498. }
  499. - (void)clearImage {
  500. dispatch_async(dispatch_get_main_queue(), ^{
  501. self.showImageView.image = nil;
  502. });
  503. }
  504. - (UIImage *)showDir:(PanoramaOrientationViewDirectionEnum)dir image:(UIImage *)image {
  505. switch (dir) {
  506. case PanoramaOrientationViewUp: {
  507. UIImage *flipImage = [UIImage imageWithCGImage:image.CGImage scale:image.scale orientation:UIImageOrientationRight];
  508. return flipImage;
  509. }
  510. break;
  511. case PanoramaOrientationViewDown: {
  512. UIImage *flipImage = [UIImage imageWithCGImage:image.CGImage scale:image.scale orientation:UIImageOrientationLeft];
  513. return flipImage;
  514. }
  515. break;
  516. case PanoramaOrientationViewLeft: {
  517. return image;
  518. }
  519. break;
  520. case PanoramaOrientationViewRight: {
  521. UIImage *flipImage = [UIImage imageWithCGImage:image.CGImage scale:image.scale orientation:UIImageOrientationUpMirrored];
  522. return flipImage;
  523. }
  524. break;
  525. default:
  526. break;
  527. }
  528. return nil;
  529. }
  530. - (void)setHidden:(BOOL)hidden{
  531. [super setHidden:hidden];
  532. self.label.hidden = hidden;
  533. }
  534. - (void)awakeFromNib{
  535. [super awakeFromNib];
  536. self.container = [[PanoramaGuideViewPreviewContainer alloc] initWithFrame:CGRectMake(0, 0, 50, 50) device:[Renderer shared].device];
  537. self.container.clearColor = MTLClearColorMake(0, 0, 0, 1);
  538. self.container.backgroundColor = [UIColor redColor];
  539. [self addSubview:self.container];
  540. self.container.delegate = self;
  541. self.container.sampleCount = 1;
  542. self.container.colorPixelFormat = MTLPixelFormatBGRA8Unorm;
  543. [self.container mas_makeConstraints:^(MASConstraintMaker *make) {
  544. make.left.top.equalTo(self);
  545. make.height.equalTo(self);
  546. make.width.equalTo(@(50));
  547. }];
  548. [[Renderer shared] setup];
  549. }
  550. - (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size{
  551. [[Renderer shared] mtkView:view drawableSizeWillChange:size];
  552. }
  553. - (void)drawInMTKView:(MTKView *)view{
  554. [[Renderer shared] drawInMTKView:view];
  555. }
  556. - (YYLabel *)label{
  557. if (_label == nil) {
  558. NSAttributedString *att = [[NSAttributedString alloc]initWithString:@"请沿箭头方向匀速拍摄"];
  559. _label = [[YYLabel alloc]init];
  560. // _label.numberOfLines = 0;
  561. _label.backgroundColor = [UIColor jk_colorWithHexString:@"000000" andAlpha:0.35];
  562. _label.attributedText = att;
  563. _label.textAlignment = NSTextAlignmentCenter;
  564. _label.layer.cornerRadius = 3;
  565. _label.layer.masksToBounds = YES;
  566. // _label.textVerticalAlignment = YYTextVerticalAlignmentCenter; // 文字置顶显示
  567. _label.textColor = UIColor.whiteColor;
  568. }
  569. return _label;
  570. }
  571. - (UIImageView *)showImageView {
  572. if (!_showImageView) {
  573. _showImageView = [[UIImageView alloc]init];
  574. _showImageView.contentMode = UIViewContentModeScaleAspectFill;
  575. _showImageView.clipsToBounds = YES;
  576. }
  577. return _showImageView;
  578. }
  579. - (UIView *)line{
  580. if (_line == nil) {
  581. _line = [[UIView alloc]init];
  582. _line.backgroundColor = UIColor.yellowColor;
  583. }
  584. return _line;
  585. }
  586. - (UIImageView *)whiteArrow{
  587. if (_whiteArrow == nil) {
  588. _whiteArrow = [[UIImageView alloc]initWithImage:[UIImage loadNamed:@"ai_right_arrow"]];
  589. }
  590. return _whiteArrow;
  591. }
  592. /*
  593. // Only override drawRect: if you perform custom drawing.
  594. // An empty implementation adversely affects performance during animation.
  595. - (void)drawRect:(CGRect)rect {
  596. // Drawing code
  597. }
  598. */
  599. @end