Commit 1bd7c2c270b8311fd35cf1662d70fc0653e10c3a
1 parent
64f045c6
功能按钮更换
Showing
4 changed files
with
47 additions
and
28 deletions
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCLiveViewController.m
| ... | ... | @@ -47,6 +47,8 @@ |
| 47 | 47 | [self.view addSubview:self.quitButton]; |
| 48 | 48 | [self.view addSubview:self.changeCameraButton]; |
| 49 | 49 | [self.view addSubview:self.openFilterButton]; |
| 50 | + [self.view addSubview:self.openFlashButton]; | |
| 51 | + [self.view addSubview:self.filterView]; | |
| 50 | 52 | |
| 51 | 53 | // 初始化推流 |
| 52 | 54 | NSString *activityId = [NSString stringWithFormat:@"%d%d%d%d%d",arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9]; |
| ... | ... | @@ -62,8 +64,6 @@ |
| 62 | 64 | [self setStreamerCfg]; |
| 63 | 65 | |
| 64 | 66 | [self addObservers]; |
| 65 | - | |
| 66 | - [self addButton:@"闪光灯" frame:CGRectMake(190, 100, 80, 40) action:@selector(openFlash)]; | |
| 67 | 67 | |
| 68 | 68 | UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; |
| 69 | 69 | singleRecognizer.delegate = self; |
| ... | ... | @@ -104,20 +104,15 @@ |
| 104 | 104 | #pragma mark - UIButton Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 105 | 105 | - (void)startCapture:(UIButton *)button { // 开始推流 |
| 106 | 106 | |
| 107 | - button.selected = !button.selected; | |
| 107 | + [_prepareView removeFromSuperview]; | |
| 108 | 108 | |
| 109 | - if (button.selected) { | |
| 110 | - [_kitCN startStream:^{ | |
| 111 | - NSLog(@"开启推流成功 ------- success"); | |
| 112 | - } failure:^(NSDictionary *errorDic) { | |
| 113 | - NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding]; | |
| 114 | - NSLog(@"%@",str); | |
| 115 | - [self toast:errorDic[@"errorMessage"]]; | |
| 116 | - }]; | |
| 117 | - }else{ | |
| 118 | - | |
| 119 | - [_kitCN stopStream]; | |
| 120 | - } | |
| 109 | + [_kitCN startStream:^{ | |
| 110 | + NSLog(@"开启推流成功 ------- success"); | |
| 111 | + } failure:^(NSDictionary *errorDic) { | |
| 112 | + NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding]; | |
| 113 | + NSLog(@"%@",str); | |
| 114 | + [self toast:errorDic[@"errorMessage"]]; | |
| 115 | + }]; | |
| 121 | 116 | } |
| 122 | 117 | |
| 123 | 118 | |
| ... | ... | @@ -149,14 +144,14 @@ |
| 149 | 144 | } else { |
| 150 | 145 | |
| 151 | 146 | _filterView.hidden = YES; |
| 152 | - | |
| 153 | 147 | } |
| 154 | 148 | } |
| 155 | 149 | |
| 156 | 150 | |
| 157 | 151 | - (void)changeCamera:(UIButton *)button { // 转换前后置摄像头 |
| 158 | 152 | |
| 159 | -// button.selected = !button.selected; | |
| 153 | + button.selected = !button.selected; | |
| 154 | + _openFlashButton.hidden = !_openFlashButton.hidden; | |
| 160 | 155 | // if (button.selected) { |
| 161 | 156 | // _kitCN.cameraPosition = AVCaptureDevicePositionBack; |
| 162 | 157 | // }else{ |
| ... | ... | @@ -167,8 +162,9 @@ |
| 167 | 162 | } |
| 168 | 163 | |
| 169 | 164 | |
| 170 | -- (void)openFlash { // 闪光灯 | |
| 165 | +- (void)openFlash:(UIButton *)button { // 闪光灯 | |
| 171 | 166 | |
| 167 | + button.selected = !button.selected; | |
| 172 | 168 | [_kitCN toggleTorch]; |
| 173 | 169 | // [_kitCN setTorchMode:AVCaptureTorchModeOn]; |
| 174 | 170 | } |
| ... | ... | @@ -195,6 +191,10 @@ |
| 195 | 191 | CGPoint point = [self convertToPointOfInterestFromViewCoordinates:current]; |
| 196 | 192 | [_kitCN exposureAtPoint:point]; |
| 197 | 193 | [_kitCN focusAtPoint:point]; |
| 194 | + | |
| 195 | + if ([_prepareView.titleTextField isFirstResponder]) { | |
| 196 | + [_prepareView.titleTextField resignFirstResponder]; | |
| 197 | + } | |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | #pragma mark - notification !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| ... | ... | @@ -399,10 +399,22 @@ |
| 399 | 399 | if (!_prepareView) { |
| 400 | 400 | _prepareView = [[LVCUGCLivePrepareView alloc] initWithFrame:self.view.bounds]; |
| 401 | 401 | [_prepareView.startButton addTarget:self action:@selector(startCapture:) forControlEvents:UIControlEventTouchUpInside]; |
| 402 | + UITapGestureRecognizer * tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; | |
| 403 | + tapRecognizer.delegate = self; | |
| 404 | + [_prepareView addGestureRecognizer:tapRecognizer]; | |
| 402 | 405 | } |
| 403 | 406 | return _prepareView; |
| 404 | 407 | } |
| 405 | 408 | |
| 409 | +- (FilterFunctionView *)filterView | |
| 410 | +{ | |
| 411 | + if (!_filterView) { | |
| 412 | + _filterView = [[FilterFunctionView alloc] initWithFrame:CGRectMake(0, 75, SCREEN_WIDTH, 200)]; | |
| 413 | + _filterView.hidden = YES; | |
| 414 | + } | |
| 415 | + return _filterView; | |
| 416 | +} | |
| 417 | + | |
| 406 | 418 | - (UIView *)captureView { // 拍摄视图 |
| 407 | 419 | |
| 408 | 420 | if (!_captureView) { |
| ... | ... | @@ -415,7 +427,7 @@ |
| 415 | 427 | - (UIButton *)quitButton { |
| 416 | 428 | |
| 417 | 429 | if (!_quitButton) { |
| 418 | - _quitButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 50, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"]; | |
| 430 | + _quitButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 50, 30, 35, 35) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"]; | |
| 419 | 431 | [_quitButton addTarget:self action:@selector(quitBtnClick) forControlEvents:UIControlEventTouchUpInside]; |
| 420 | 432 | } |
| 421 | 433 | return _quitButton; |
| ... | ... | @@ -424,7 +436,7 @@ |
| 424 | 436 | - (UIButton *)changeCameraButton { |
| 425 | 437 | |
| 426 | 438 | if (!_changeCameraButton) { |
| 427 | - _changeCameraButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 100, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"]; | |
| 439 | + _changeCameraButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 100, 30, 35, 35) image:@"camera" selected:@"Select the camera"]; | |
| 428 | 440 | [_changeCameraButton addTarget:self action:@selector(changeCamera:) forControlEvents:UIControlEventTouchUpInside]; |
| 429 | 441 | } |
| 430 | 442 | return _changeCameraButton; |
| ... | ... | @@ -433,7 +445,9 @@ |
| 433 | 445 | - (UIButton *)openFlashButton { |
| 434 | 446 | |
| 435 | 447 | if (!_openFlashButton) { |
| 436 | - | |
| 448 | + _openFlashButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 100, 75, 35, 35) image:@"open flash" selected:@"Flash off"]; | |
| 449 | + _openFlashButton.hidden = YES; | |
| 450 | + [_openFlashButton addTarget:self action:@selector(openFlash:) forControlEvents:UIControlEventTouchUpInside]; | |
| 437 | 451 | } |
| 438 | 452 | return _openFlashButton; |
| 439 | 453 | } |
| ... | ... | @@ -441,7 +455,7 @@ |
| 441 | 455 | - (UIButton *)openFilterButton { |
| 442 | 456 | |
| 443 | 457 | if (!_openFilterButton) { |
| 444 | - _openFilterButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 150, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"]; | |
| 458 | + _openFilterButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 150, 30, 35, 35) image:@"Is closed" selected:@"Is open"]; | |
| 445 | 459 | [_openFilterButton addTarget:self action:@selector(openFilter:) forControlEvents:UIControlEventTouchUpInside]; |
| 446 | 460 | } |
| 447 | 461 | return _openFilterButton; | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/FilterFunctionView.m
| ... | ... | @@ -135,7 +135,7 @@ |
| 135 | 135 | - (UIPickerView *)effectPicker |
| 136 | 136 | { |
| 137 | 137 | if (!_effectPicker) { |
| 138 | - _effectPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(8, 130, self.bounds.size.width-16, 100)]; | |
| 138 | + _effectPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(8, 20, self.bounds.size.width-16, 100)]; | |
| 139 | 139 | _effectPicker.showsSelectionIndicator=YES; |
| 140 | 140 | _effectPicker.tintColor = [UIColor whiteColor]; |
| 141 | 141 | _effectPicker.dataSource = self; | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLivePrepareView.h
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLivePrepareView.m
| ... | ... | @@ -12,8 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | @property (nonatomic, strong) UIImageView *iconView; |
| 14 | 14 | |
| 15 | -@property (nonatomic, strong) UITextField *titleTextField; | |
| 16 | - | |
| 17 | 15 | @property (nonatomic, strong) UIView *lineView; |
| 18 | 16 | |
| 19 | 17 | @end |
| ... | ... | @@ -51,8 +49,13 @@ |
| 51 | 49 | |
| 52 | 50 | if (!_titleTextField) { |
| 53 | 51 | _titleTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, SCREEN_HEIGHT * 0.35 + 50, SCREEN_WIDTH - 120, 30)]; |
| 54 | - _titleTextField.placeholder = @"起一个名字开始直播吧~"; | |
| 55 | - _titleTextField.font = [UIFont systemFontOfSize:20]; | |
| 52 | + | |
| 53 | + NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:@"起个名字开始直播~"]; | |
| 54 | + | |
| 55 | + | |
| 56 | + _titleTextField.attributedPlaceholder = placeholder; | |
| 57 | + | |
| 58 | + _titleTextField.font = [UIFont systemFontOfSize:19]; | |
| 56 | 59 | } |
| 57 | 60 | return _titleTextField; |
| 58 | 61 | } |
| ... | ... | @@ -70,7 +73,7 @@ |
| 70 | 73 | |
| 71 | 74 | if (!_startButton) { |
| 72 | 75 | _startButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 73 | - _startButton.frame = CGRectMake(30, SCREEN_HEIGHT * 0.6, SCREEN_WIDTH - 60, 38); | |
| 76 | + _startButton.frame = CGRectMake(30, SCREEN_HEIGHT * 0.62, SCREEN_WIDTH - 60, 38); | |
| 74 | 77 | _startButton.backgroundColor = [UIColor redColor]; |
| 75 | 78 | [_startButton setTitle:@"开始直播" forState:UIControlStateNormal]; |
| 76 | 79 | _startButton.titleLabel.font = [UIFont systemFontOfSize:20]; | ... | ... |