PlayerView.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. //
  2. // PlayerView.m
  3. // VclustersGemini
  4. //
  5. // Created by APPLE on 2019/6/13.
  6. // Copyright © 2019 APPLE. All rights reserved.
  7. //
  8. #import "PlayerView.h"
  9. #import "UIView+View.h"
  10. @interface PlayerView ()
  11. <UIGestureRecognizerDelegate,
  12. ShowImageViewDelegate>{
  13. EAGLContext *eagContext;
  14. CIContext *ciContext;
  15. CIFilter *filter;
  16. //触控指令视图,用于计算触控位置坐标
  17. ShowImageView *touchCommondView;
  18. UIView *bottomContrView;
  19. UIButton *mueBtn;
  20. UIButton *homeBtn;
  21. UIButton *backBtn;
  22. UIButton *showHomeBtn;
  23. NSTimer *hideBottomTimer;
  24. }
  25. @end
  26. @implementation PlayerView
  27. @synthesize showImageView;
  28. @synthesize glkshowImageView;
  29. @synthesize controlBtn;
  30. @synthesize delegate;
  31. @synthesize isLan;
  32. - (id)initWithFrame:(CGRect)frame{
  33. self = [super initWithFrame:frame];
  34. if (self){
  35. [self setBackgroundColor:[UIColor blackColor]];
  36. [self initOpenGL];
  37. [self drawView:frame];
  38. }
  39. return self;
  40. }
  41. - (void)initOpenGL{
  42. eagContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
  43. ciContext = [CIContext contextWithEAGLContext:eagContext
  44. options:@{kCIContextWorkingColorSpace:[NSNull null]}];
  45. filter = [CIFilter filterWithName:@"CISepiaTone"];
  46. }
  47. - (void)glkShowImage:(CIImage *)ciImage{
  48. [filter setValue:ciImage forKey:kCIInputImageKey];
  49. [filter setValue:@(0) forKey:kCIInputIntensityKey];
  50. //开始渲染
  51. [ciContext drawImage:[filter valueForKey:kCIOutputImageKey]
  52. inRect:CGRectMake(0, 0, glkshowImageView.drawableWidth, glkshowImageView.drawableHeight)
  53. fromRect:[ciImage extent]];
  54. [self->glkshowImageView display];
  55. }
  56. - (void)showIMage
  57. {
  58. ;
  59. }
  60. - (void)drawView:(CGRect)frame{
  61. self.frame = frame;
  62. touchCommondView = [[ShowImageView alloc] init];
  63. [touchCommondView setBackgroundColor: [UIColor clearColor]];
  64. [touchCommondView setUserInteractionEnabled:YES];
  65. touchCommondView.multipleTouchEnabled = YES;
  66. touchCommondView.delegate = self;
  67. [self addSubview:touchCommondView];
  68. [touchCommondView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.mas_equalTo(0.f);
  70. make.height.mas_equalTo(frame.size.height);
  71. make.right.mas_equalTo(0.f);
  72. make.top.mas_equalTo(0.f);
  73. }];
  74. //此方案弃用
  75. // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapBeganFun)];
  76. // [touchCommondView addGestureRecognizer:tap];
  77. /*播放视图*/
  78. showImageView = [[ShowImageView alloc] init];
  79. [showImageView setBackgroundColor: [UIColor blackColor]];
  80. [showImageView setUserInteractionEnabled:NO];
  81. [showImageView setBackgroundColor:[UIColor blackColor]];
  82. glkshowImageView = [[GLKView alloc] initWithFrame:self.frame context:eagContext];
  83. [glkshowImageView setBackgroundColor:[UIColor blackColor]];
  84. [glkshowImageView bindDrawable];
  85. [glkshowImageView setUserInteractionEnabled:NO];
  86. [touchCommondView addSubview:showImageView];
  87. [showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(0.f);
  89. make.right.mas_equalTo(0.f);
  90. make.bottom.mas_equalTo(0.f);
  91. make.top.mas_equalTo(0.f);
  92. }];
  93. [touchCommondView addSubview:glkshowImageView];
  94. [glkshowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.mas_equalTo(0.f);
  96. make.right.mas_equalTo(0.f);
  97. make.bottom.mas_equalTo(0.f);
  98. make.top.mas_equalTo(0.f);
  99. }];
  100. /*控制按钮*/
  101. UIImage *driftBtnImage = [UIImage imageNamed:@"you_icon"];
  102. controlBtn = [[UIButton alloc] init];
  103. [controlBtn setBackgroundColor:[UIColor clearColor]];
  104. [controlBtn addTarget:self
  105. action:@selector(controlBtnPressed:)
  106. forControlEvents:(UIControlEventTouchUpInside)];
  107. UIPanGestureRecognizer *gester = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCallback:)];
  108. [controlBtn addGestureRecognizer:gester];
  109. gester.delegate = self;
  110. gester = nil;
  111. //[controlBtn setImage:driftBtnImage forState:(UIControlStateNormal)];
  112. [controlBtn setBackgroundImage:driftBtnImage forState:(UIControlStateNormal)];
  113. [controlBtn addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(controlBtnLongPress:)]];
  114. /*下方控制器*/
  115. bottomContrView = [[UIView alloc] initWithFrame:CGRectMake(0, frame.size.height - 47.f, frame.size.width, 47.f)];
  116. [bottomContrView setBackgroundColor:[UIColor blackColor]];
  117. [self addSubview:bottomContrView];
  118. [bottomContrView mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.right.mas_equalTo(0);
  120. make.height.mas_equalTo(47.f);
  121. make.left.mas_equalTo(0.f);
  122. make.bottom.mas_equalTo(0.f);
  123. }];
  124. [bottomContrView setHidden:YES];
  125. [self initAddSubViewForBottomContrView];
  126. [self setPoMas_makeWithImageRate:frame.size.width/frame.size.height isOpenVirtual:NO isUsageMode:NO];
  127. }
  128. - (void)initAddSubViewForBottomContrView{
  129. /*第一个app菜单*/
  130. UIImage *mueBtnImage = [UIImage imageNamed:@"houtai_icon"];
  131. mueBtn = [[UIButton alloc] init];
  132. [mueBtn setBackgroundColor:[UIColor clearColor]];
  133. [mueBtn addTarget:self
  134. action:@selector(mueBtnPressed:)
  135. forControlEvents:(UIControlEventTouchUpInside)];
  136. [mueBtn setImage:mueBtnImage forState:(UIControlStateNormal)];
  137. [mueBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  138. [bottomContrView addSubview:mueBtn];
  139. /*第二个home键*/
  140. UIImage *homeBtnImage = [UIImage imageNamed:@"home_icon"];
  141. homeBtn = [[UIButton alloc] init];
  142. [homeBtn setBackgroundColor:[UIColor clearColor]];
  143. [homeBtn addTarget:self
  144. action:@selector(homeBtnPressed:)
  145. forControlEvents:(UIControlEventTouchUpInside)];
  146. [homeBtn setImage:homeBtnImage forState:(UIControlStateNormal)];
  147. [homeBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  148. [bottomContrView addSubview:homeBtn];
  149. /*第三个返回键*/
  150. UIImage *backBtnImage = [UIImage imageNamed:@"fanhui_you_icon"];
  151. backBtn = [[UIButton alloc] init];
  152. [backBtn setBackgroundColor:[UIColor clearColor]];
  153. [backBtn addTarget:self
  154. action:@selector(backBtnPressed:)
  155. forControlEvents:(UIControlEventTouchUpInside)];
  156. [backBtn setImage:backBtnImage forState:(UIControlStateNormal)];
  157. [backBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  158. [bottomContrView addSubview:backBtn];
  159. //测试说图片方向反了
  160. backBtn.imageView.transform = CGAffineTransformMakeRotation(M_PI);
  161. /*第四个隐藏显示键*/
  162. UIImage *showBtnImage = [UIImage imageNamed:@"showOrhide_home_icon"];
  163. showHomeBtn = [[UIButton alloc] init];
  164. [showHomeBtn setBackgroundColor:[UIColor clearColor]];
  165. [showHomeBtn addTarget:self action:@selector(showOrHideHomeButtomFun:) forControlEvents:(UIControlEventTouchUpInside)];
  166. [showHomeBtn setImage:showBtnImage forState:(UIControlStateNormal)];
  167. [showHomeBtn setImageEdgeInsets:(UIEdgeInsetsMake(6.f, 6.f, 6.f, 6.f))];
  168. [bottomContrView addSubview:showHomeBtn];
  169. }
  170. - (void)mueBtnPressed:(id)sender{
  171. if ([delegate respondsToSelector:@selector(mueBtnBePressed:)]) {
  172. [delegate mueBtnBePressed:sender];
  173. }
  174. }
  175. - (void)homeBtnPressed:(id)sender{
  176. if ([delegate respondsToSelector:@selector(homeBtnBePressed:)]) {
  177. [delegate homeBtnBePressed:sender];
  178. }
  179. }
  180. - (void)backBtnPressed:(id)sender{
  181. if ([delegate respondsToSelector:@selector(backBtnBePressed:)]) {
  182. [delegate backBtnBePressed:sender];
  183. }
  184. }
  185. - (void)showOrHideHomeButtomFun:(UIButton*)but{
  186. but.selected = !but.selected;
  187. if(but.selected){
  188. but.imageView.transform = CGAffineTransformMakeRotation(M_PI);
  189. }
  190. else{
  191. but.imageView.transform = CGAffineTransformMakeRotation(0);
  192. }
  193. [self setShowOrHideBottomButtonsFunBy:but.selected];
  194. }
  195. - (void)initPoMas_makeWithImageRate:(BOOL)isOpenVirtual isUsageMode:(BOOL)isUsageMode{
  196. [self setPoMas_makeWithImageRate:self.frame.size.width/self.frame.size.height isOpenVirtual:isOpenVirtual isUsageMode:isUsageMode];
  197. }
  198. - (void)setPoMas_makeWithImageRate:(CGFloat)w_h_rate isOpenVirtual:(BOOL)isOpenVirtual isUsageMode:(BOOL)isUsageMode{
  199. /*播放视图*/
  200. // touchCommondView.isLan = NO;
  201. [showImageView setBackgroundColor:[UIColor blackColor]];
  202. [touchCommondView mas_remakeConstraints:^(MASConstraintMaker *make) {
  203. CGFloat scr_W = SCREEN_W;
  204. CGFloat scr_H = SCREEN_H;
  205. if (SCREEN_W > SCREEN_H){
  206. scr_W = SCREEN_H;
  207. scr_H = SCREEN_W;
  208. }
  209. if ((scr_H - scr_W/w_h_rate - 40.f)/2.f < 0){
  210. if(fullScreenShow){
  211. make.height.mas_equalTo(scr_H);
  212. make.width.mas_equalTo(scr_W);
  213. }
  214. else{
  215. make.height.mas_equalTo(scr_H - 40.f);
  216. make.width.mas_equalTo((scr_H - 40.f)*w_h_rate);
  217. }
  218. make.centerX.equalTo(self.mas_centerX);
  219. make.top.mas_equalTo(0);
  220. }
  221. else{
  222. make.left.mas_equalTo(0.f);
  223. make.right.mas_equalTo(0.f);
  224. if(fullScreenShow){
  225. make.height.mas_equalTo(scr_H - TABBARHEIGHT);
  226. make.top.mas_equalTo(0.f);
  227. }
  228. else{
  229. make.height.mas_equalTo(scr_W/w_h_rate);
  230. make.top.mas_equalTo((scr_H - scr_W/w_h_rate - 40.f)/2.f);
  231. }
  232. }
  233. }];
  234. [showImageView setTransform:CGAffineTransformMakeRotation(0)];
  235. [glkshowImageView setTransform:CGAffineTransformMakeRotation(0)];
  236. [showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  237. make.left.equalTo(touchCommondView.mas_left);
  238. make.right.equalTo(touchCommondView.mas_right);
  239. make.top.equalTo(touchCommondView.mas_top);
  240. make.bottom.equalTo(touchCommondView.mas_bottom);
  241. }];
  242. [self.glkshowImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  243. make.left.equalTo(touchCommondView.mas_left);
  244. make.right.equalTo(touchCommondView.mas_right);
  245. make.top.equalTo(touchCommondView.mas_top);
  246. make.bottom.equalTo(touchCommondView.mas_bottom);
  247. }];
  248. [bottomContrView setHidden:NO];
  249. [bottomContrView mas_remakeConstraints:^(MASConstraintMaker *make) {
  250. make.height.mas_equalTo(40.f);
  251. make.right.equalTo(touchCommondView.mas_right);
  252. make.top.equalTo(touchCommondView.mas_bottom);
  253. make.left.equalTo(touchCommondView.mas_left);
  254. }];
  255. [mueBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  256. make.left.mas_equalTo(80.f);
  257. make.width.and.height.mas_equalTo(40.f);
  258. make.top.mas_equalTo(0);
  259. }];
  260. [homeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  261. make.centerX.equalTo(bottomContrView.mas_centerX);
  262. make.width.and.height.mas_equalTo(40.f);
  263. make.top.mas_equalTo(0);
  264. }];
  265. UIImage *backBtnImage = [UIImage imageNamed:@"fanhui_you_icon"];
  266. // UIImage *backBtnImage = [UIImage imageNamed:@"fanhui_icon"];
  267. [backBtn setImage:backBtnImage forState:(UIControlStateNormal)];
  268. [backBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  269. make.right.mas_equalTo(-80.f);
  270. make.width.and.height.mas_equalTo(40.f);
  271. make.top.mas_equalTo(0);
  272. }];
  273. [showHomeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  274. make.right.mas_equalTo(-20.f);
  275. make.width.and.height.mas_equalTo(40.f);
  276. make.top.mas_equalTo(0);
  277. }];
  278. }
  279. /**
  280. * @brief 设置横屏模式UI布局
  281. *
  282. * @param w_h_rate 宽高比
  283. *
  284. * @param isOpenVirtual 是否有打开底部虚拟按键
  285. *
  286. * @param isUsageMode 是否为专业模式
  287. *
  288. */
  289. - (void)setLanMas_makeWithImageRate:(CGFloat)w_h_rate isOpenVirtual:(BOOL)isOpenVirtual isUsageMode:(BOOL)isUsageMode{
  290. /*需要考虑专业模式*/
  291. /*暂时只考虑非专业模式无虚拟键布局*/
  292. CGFloat h_forPhoneTop = 0;
  293. if (IPHONE_X){
  294. h_forPhoneTop = 44.f;
  295. }
  296. CGFloat des_W = SCREEN_W<SCREEN_H?SCREEN_W:SCREEN_H;/*实际较小的数字*/
  297. CGFloat des_H = (SCREEN_W>SCREEN_H?SCREEN_W:SCREEN_H) - h_forPhoneTop;/*实际较大的数字*/
  298. // touchCommondView.isLan = YES;
  299. [touchCommondView mas_remakeConstraints:^(MASConstraintMaker *make) {
  300. make.bottom.mas_equalTo(0.f);
  301. make.width.mas_equalTo(des_W*w_h_rate);
  302. make.left.mas_equalTo(h_forPhoneTop + (des_H - des_W*w_h_rate)/2.f);
  303. make.top.mas_equalTo(0);
  304. }];
  305. CGFloat des_H1 = des_W*w_h_rate;/*实际较大的数字*/
  306. CGFloat des_W1 = des_W;/*实际较小的数字*/
  307. if (isUsageMode){
  308. des_W1 = des_W-44.f;
  309. des_H1 = (des_W-44.f)*w_h_rate;
  310. }
  311. [showImageView setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
  312. [glkshowImageView setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
  313. [showImageView setBackgroundColor:[UIColor blackColor]];
  314. [showImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  315. make.height.mas_equalTo(des_H1);
  316. make.width.mas_equalTo((des_W1));
  317. make.left.mas_equalTo((des_H1 - des_W1)/2.f);
  318. make.top.mas_equalTo((des_W1 - des_H1)/2.f);
  319. }];
  320. [self.glkshowImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
  321. /*动态处理宽高*/
  322. make.height.mas_equalTo(des_H1);
  323. make.width.mas_equalTo((des_W1));
  324. make.left.mas_equalTo((des_H1 - des_W1)/2.f);
  325. make.top.mas_equalTo((des_W1 - des_H1)/2.f);
  326. }];
  327. }
  328. - (void)controlBtnPressed:(id)sender{
  329. if ([delegate respondsToSelector:@selector(useInfoBtnBePressed:)]) {
  330. [delegate useInfoBtnBePressed:sender];
  331. }
  332. }
  333. static int sendCount = 0;
  334. #pragma -mark showImageViewDelegate
  335. - (void)showImageViewtouchesBeganCommondStr:(NSString *)commondStr{
  336. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  337. sendCount = 1;
  338. [delegate playerShowImageViewtouchesStr:commondStr];
  339. HLog(@"\n-----showImageViewtouchesBeganCommondStr-----");
  340. }
  341. }
  342. - (void)showImageViewtouchesEndedCommondStr:(NSString *)commondStr{
  343. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  344. HLog(@"\n-----showImageViewtouchesEndedCommondStr-----");
  345. sendCount = 0;
  346. [delegate playerShowImageViewtouchesStr:commondStr];
  347. }
  348. }
  349. - (void)showImageViewtouchesMovedCommondStr:(NSString *)commondStr{
  350. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  351. HLog(@"\n-----showImageViewtouchesMovedCommondStr-----");
  352. if (sendCount%2 == 0){
  353. [delegate playerShowImageViewtouchesStr:commondStr];
  354. }
  355. sendCount++;
  356. }
  357. }
  358. - (void)showImageViewtouchesCancelledCommondStr:(NSString *)commondStr{
  359. if ([delegate respondsToSelector:@selector(playerShowImageViewtouchesStr:)]){
  360. HLog(@"\n-----showImageViewtouchesCancelledCommondStr-----");
  361. sendCount = 0;
  362. [delegate playerShowImageViewtouchesStr:commondStr];
  363. }
  364. }
  365. - (void)controlBtnLongPress:(UILongPressGestureRecognizer *)longPressGesture {
  366. switch (longPressGesture.state) {
  367. case UIGestureRecognizerStateBegan:{
  368. // HLog(@"云手机推流界面 控制按钮长按手势开始");
  369. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchBeganNotification object:nil userInfo:nil];
  370. break;
  371. case UIGestureRecognizerStateEnded:{
  372. // HLog(@"云手机推流界面 控制按钮长按手势结束");
  373. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchEndNotification object:nil userInfo:nil];
  374. break;
  375. }
  376. default:
  377. break;
  378. }
  379. }
  380. }
  381. static CGRect startFrame;
  382. - (void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{
  383. self.controlBtn.alpha = 1;
  384. switch (panGesture.state) {
  385. case UIGestureRecognizerStateBegan:{
  386. startFrame = controlBtn.frame;
  387. // HLog(@"云手机推流界面 控制按钮拖动手势开始");
  388. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchBeganNotification object:nil userInfo:nil];
  389. break;
  390. }
  391. case UIGestureRecognizerStateChanged:{
  392. CGPoint translatedPoint = [panGesture translationInView:self];/*KXLY*/
  393. CGRect frame = controlBtn.frame;
  394. frame.origin.x = translatedPoint.x + startFrame.origin.x;
  395. frame.origin.y = translatedPoint.y + startFrame.origin.y;
  396. controlBtn.frame = frame;
  397. // HLog(@"\n--(%f,%f)--controlBtn.frame--X-%f",translatedPoint.x,translatedPoint.x,controlBtn.frame.origin.x);
  398. break;
  399. }
  400. case UIGestureRecognizerStateEnded:
  401. // HLog(@"云手机推流界面 控制按钮拖动手势结束");
  402. [[NSNotificationCenter defaultCenter] postNotificationName:PlayerViewControlBtnTouchEndNotification object:nil userInfo:nil];
  403. /*防止控制器移出屏幕*/
  404. CGRect frame = controlBtn.frame;
  405. if (frame.origin.x < 10.f/2.f){
  406. frame.origin.x = 10.f/2.f;
  407. }
  408. if (frame.origin.y < 10.f/2.f + H_STATE_BAR){
  409. frame.origin.y = 10.f/2.f + H_STATE_BAR;
  410. }
  411. if (frame.size.width + frame.origin.x + 10.f/2.f > self.width){
  412. frame.origin.x = self.width - 10.f/2.f - frame.size.width;
  413. }
  414. if (frame.size.height + frame.origin.y + 10.f/2.f > self.height){
  415. frame.origin.y = self.height - 10.f/2.f - frame.size.height;
  416. }
  417. controlBtn.frame = frame;
  418. break;
  419. case UIGestureRecognizerStateCancelled: {
  420. /*防止控制器移出屏幕*/
  421. CGRect frame = controlBtn.frame;
  422. if (frame.origin.x < 10.f/2.f){
  423. frame.origin.x = 10.f/2.f;
  424. }
  425. if (frame.origin.y < 10.f/2.f + H_STATE_BAR){
  426. frame.origin.y = 10.f/2.f + H_STATE_BAR;
  427. }
  428. if (frame.size.width + frame.origin.x + 10.f/2.f > self.width){
  429. frame.origin.x = self.width - 10.f/2.f - frame.size.width;
  430. }
  431. if (frame.size.height + frame.origin.y + 10.f/2.f > self.height){
  432. frame.origin.y = self.height - 10.f/2.f - frame.size.height;
  433. }
  434. controlBtn.frame = frame;
  435. break;
  436. }
  437. default:
  438. break;
  439. }
  440. }
  441. - (void)setIsLan:(BOOL)isLan{
  442. self->isLan = isLan;
  443. /*设置视图方向*/
  444. showImageView.isLan = isLan;
  445. touchCommondView.isLan = isLan;
  446. //[self setShowOrHideBottomButtonsFunBy:isLan];
  447. }
  448. - (void)setShowOrHideBottomButtonsFunBy:(BOOL)isHide
  449. {
  450. mainBlock(^{
  451. self->mueBtn.hidden = isHide;
  452. self->homeBtn.hidden = isHide;
  453. self->backBtn.hidden = isHide;
  454. });
  455. }
  456. #pragma mark 点击屏幕出来
  457. - (void)didTapBeganFun
  458. {
  459. if(!isLan){
  460. return;
  461. }
  462. // if(![commondStr containsString:@"\"count\":1"]){
  463. // return;
  464. // }
  465. if(mueBtn.hidden){
  466. [self setShowOrHideBottomButtonsFunBy:NO];
  467. [hideBottomTimer invalidate];
  468. hideBottomTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(timerToHideBottomButtonFun) userInfo:nil repeats:NO];
  469. [[NSRunLoop currentRunLoop] addTimer:hideBottomTimer forMode:NSRunLoopCommonModes];
  470. }
  471. else{
  472. [self setShowOrHideBottomButtonsFunBy:YES];
  473. [hideBottomTimer invalidate];
  474. }
  475. }
  476. - (void)timerToHideBottomButtonFun
  477. {
  478. [hideBottomTimer invalidate];
  479. if(!isLan){
  480. return;
  481. }
  482. [self setShowOrHideBottomButtonsFunBy:YES];
  483. }
  484. @end