turntableRuleView.m 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // turntableRuleView.m
  3. // yunbaolive
  4. //
  5. // Created by IOS1 on 2019/8/24.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "turntableRuleView.h"
  9. #import <WebKit/WebKit.h>
  10. @implementation turntableRuleView{
  11. UIView *whiteView;
  12. WKWebView *_webView;
  13. }
  14. -(instancetype)init{
  15. self = [super init];
  16. if (self) {
  17. self.frame = CGRectMake(0, 0, _window_width, _window_height);
  18. self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
  19. [self creatUI];
  20. }
  21. return self;
  22. }
  23. - (void)creatUI{
  24. whiteView = [[UIView alloc]initWithFrame:CGRectMake(_window_width*0.1, (_window_height-_window_width*0.88)/2, _window_width*0.8, _window_width*0.88)];
  25. whiteView.backgroundColor = [UIColor whiteColor];
  26. whiteView.layer.cornerRadius = 10.0;
  27. whiteView.layer.masksToBounds = YES;
  28. [self addSubview:whiteView];
  29. UILabel *titleL = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, whiteView.width, whiteView.width*0.2)];
  30. titleL.text = YZMsg(@"游戏规则");
  31. titleL.font = [UIFont boldSystemFontOfSize:15];
  32. titleL.textAlignment = NSTextAlignmentCenter;
  33. [whiteView addSubview:titleL];
  34. UIButton *sureBtn = [UIButton buttonWithType:0];
  35. sureBtn.frame = CGRectMake(0, whiteView.height-whiteView.width/6, whiteView.width, whiteView.width/6);
  36. [sureBtn setTitle:YZMsg(@"确定") forState:0];
  37. sureBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
  38. [sureBtn setTitleColor:[UIColor blackColor] forState:0];
  39. [sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
  40. [whiteView addSubview:sureBtn];
  41. _webView = [[WKWebView alloc]init];
  42. _webView.backgroundColor = [UIColor whiteColor];
  43. NSString *paths = [h5url stringByAppendingString:@"/portal/page/index?id=152"];//id=35
  44. paths = [paths stringByAppendingFormat:@"&lang=%@",[YBLanguageTools serviceLang]];
  45. NSURL *url = [NSURL URLWithString:paths];
  46. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  47. [_webView loadRequest:request];
  48. _webView.frame = CGRectMake(20, titleL.bottom, whiteView.width-40, sureBtn.top-(titleL.bottom)-1);
  49. [whiteView addSubview:_webView];
  50. [PublicObj lineViewWithFrame:CGRectMake(0, _webView.bottom, whiteView.width, 1) andColor:RGB_COLOR(@"#f0f0f0", 1) andView:whiteView];
  51. whiteView.transform = CGAffineTransformMakeScale(0.1,0.1);
  52. [self show];
  53. }
  54. - (void)show{
  55. [UIView animateWithDuration:0.3 animations:^{
  56. whiteView.transform = CGAffineTransformMakeScale(1,1);
  57. }];
  58. }
  59. - (void)sureBtnClick{
  60. [UIView animateWithDuration:0.3 animations:^{
  61. whiteView.transform = CGAffineTransformMakeScale(0.1,0.1);
  62. } completion:^(BOOL finished) {
  63. self.hidden = YES;
  64. }];
  65. }
  66. @end