Commit b291c7afe24f25486a38d6f46c34758cc3010332
1 parent
7b964133
添加滤镜文件
Showing
4 changed files
with
304 additions
and
0 deletions
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/FilterFunctionView.h
0 → 100755
| 1 | +// | |
| 2 | +// FilterFunctionView.h | |
| 3 | +// CNLivePlayerSDKDemo | |
| 4 | +// | |
| 5 | +// Created by iOS on 16/12/21. | |
| 6 | +// Copyright © 2016年 雷浩杰. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +typedef void(^FilterViewBlock)(float grindRatio , float whitenRatio, float intensity); | |
| 12 | + | |
| 13 | +typedef void(^FilterCurrentType)(NSInteger currentType); | |
| 14 | + | |
| 15 | +typedef void(^FilterCurrentIdx)(NSInteger currentIdx); | |
| 16 | + | |
| 17 | +@interface FilterFunctionView : UIView | |
| 18 | + | |
| 19 | +@property (nonatomic, copy) FilterViewBlock filterViewBlock; | |
| 20 | + | |
| 21 | +@property (nonatomic, copy) FilterCurrentType currentTypeBlock; | |
| 22 | + | |
| 23 | +@property (nonatomic, copy) FilterCurrentIdx currentIdxBlock; | |
| 24 | + | |
| 25 | +@end | |
| 26 | + | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/FilterFunctionView.m
0 → 100755
| 1 | +// | |
| 2 | +// FilterFunctionView.m | |
| 3 | +// CNLivePlayerSDKDemo | |
| 4 | +// | |
| 5 | +// Created by iOS on 16/12/21. | |
| 6 | +// Copyright © 2016年 雷浩杰. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "FilterFunctionView.h" | |
| 10 | +#import "SliderView.h" | |
| 11 | + | |
| 12 | +@interface FilterFunctionView ()<SliderViewDelegate,UIPickerViewDelegate,UIPickerViewDataSource> | |
| 13 | +{ | |
| 14 | + NSArray *_dataArr; | |
| 15 | +} | |
| 16 | + | |
| 17 | +@property (nonatomic, strong) SliderView *slider1; | |
| 18 | +@property (nonatomic, strong) SliderView *slider2; | |
| 19 | +@property (nonatomic, strong) SliderView *slider3; | |
| 20 | +@property (nonatomic, strong) UISegmentedControl * filterGroupType; | |
| 21 | +@property (nonatomic, strong) UIPickerView *effectPicker; | |
| 22 | + | |
| 23 | +@end | |
| 24 | + | |
| 25 | +@implementation FilterFunctionView | |
| 26 | + | |
| 27 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 28 | +{ | |
| 29 | + self = [super initWithFrame:frame]; | |
| 30 | + if (self) { | |
| 31 | + [self addSubview:self.slider1]; | |
| 32 | + [self addSubview:self.slider2]; | |
| 33 | + [self addSubview:self.slider3]; | |
| 34 | + [self addSubview:self.effectPicker]; | |
| 35 | + [self addSubview:self.filterGroupType]; | |
| 36 | + | |
| 37 | + _dataArr = @[@"小清新",@"靓丽",@"甜美可人",@"怀旧",@"蓝调",@"老照片"]; | |
| 38 | + | |
| 39 | + } | |
| 40 | + return self; | |
| 41 | +} | |
| 42 | + | |
| 43 | +#pragma mark - | |
| 44 | +#pragma mark - SliderViewDelegate | |
| 45 | + | |
| 46 | +- (void)sliderValueChenged | |
| 47 | +{ | |
| 48 | + if (_filterViewBlock) { | |
| 49 | + _filterViewBlock(_slider1.currentValue, _slider2.currentValue, _slider3.currentValue); | |
| 50 | + } | |
| 51 | +} | |
| 52 | + | |
| 53 | +- (void)onSegCtrl:(UISegmentedControl *)sender | |
| 54 | +{ | |
| 55 | + | |
| 56 | + if (sender.selectedSegmentIndex == 0) { | |
| 57 | + _slider1.hidden = YES; | |
| 58 | + _slider2.hidden = YES; | |
| 59 | + _slider3.hidden = YES; | |
| 60 | + _effectPicker.hidden = YES; | |
| 61 | + | |
| 62 | + } else if (sender.selectedSegmentIndex == 1) { | |
| 63 | + _slider1.hidden = NO; | |
| 64 | + _slider2.hidden = YES; | |
| 65 | + _slider3.hidden = YES; | |
| 66 | + _effectPicker.hidden = YES; | |
| 67 | + } else if (sender.selectedSegmentIndex == 2) { | |
| 68 | + _slider1.hidden = NO; | |
| 69 | + _slider2.hidden = NO; | |
| 70 | + _slider3.hidden = NO; | |
| 71 | + _effectPicker.hidden = YES; | |
| 72 | + } else { | |
| 73 | + _slider1.hidden = NO; | |
| 74 | + _slider2.hidden = NO; | |
| 75 | + _slider3.hidden = NO; | |
| 76 | + _effectPicker.hidden = NO; | |
| 77 | + } | |
| 78 | + | |
| 79 | + _currentTypeBlock ? _currentTypeBlock(sender.selectedSegmentIndex) : nil; | |
| 80 | + | |
| 81 | +} | |
| 82 | + | |
| 83 | +#pragma mark - | |
| 84 | +#pragma mark - effectPicker | |
| 85 | +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView | |
| 86 | +{ | |
| 87 | + return 1; | |
| 88 | +} | |
| 89 | + | |
| 90 | +- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component | |
| 91 | +{ | |
| 92 | + return _dataArr.count; | |
| 93 | +} | |
| 94 | + | |
| 95 | +- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component | |
| 96 | +{ | |
| 97 | + return _dataArr[row]; | |
| 98 | +} | |
| 99 | + | |
| 100 | +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component | |
| 101 | +{ | |
| 102 | + _currentIdxBlock ? _currentIdxBlock(row) : nil; | |
| 103 | +} | |
| 104 | + | |
| 105 | +#pragma mark - | |
| 106 | +#pragma mark - getter | |
| 107 | + | |
| 108 | +- (SliderView *)slider1 | |
| 109 | +{ | |
| 110 | + if (!_slider1) { | |
| 111 | + _slider1 = [[SliderView alloc] initWithFrame:CGRectMake(8, 50, self.bounds.size.width-16, 24) title:@"磨皮"]; | |
| 112 | + _slider1.delagate = self; | |
| 113 | + } | |
| 114 | + return _slider1; | |
| 115 | +} | |
| 116 | + | |
| 117 | +- (SliderView *)slider2 | |
| 118 | +{ | |
| 119 | + if (!_slider2) { | |
| 120 | + _slider2 = [[SliderView alloc] initWithFrame:CGRectMake(8, 80, self.bounds.size.width-16, 24) title:@"美白"]; | |
| 121 | + _slider2.delagate = self; | |
| 122 | + } | |
| 123 | + return _slider2; | |
| 124 | +} | |
| 125 | + | |
| 126 | +- (SliderView *)slider3 | |
| 127 | +{ | |
| 128 | + if (!_slider3) { | |
| 129 | + _slider3 = [[SliderView alloc] initWithFrame:CGRectMake(8, 110, self.bounds.size.width-16, 24) title:@"特效"]; | |
| 130 | + _slider3.delagate = self; | |
| 131 | + } | |
| 132 | + return _slider3; | |
| 133 | +} | |
| 134 | + | |
| 135 | +- (UIPickerView *)effectPicker | |
| 136 | +{ | |
| 137 | + if (!_effectPicker) { | |
| 138 | + _effectPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(8, 130, self.bounds.size.width-16, 100)]; | |
| 139 | + _effectPicker.showsSelectionIndicator=YES; | |
| 140 | + _effectPicker.tintColor = [UIColor whiteColor]; | |
| 141 | + _effectPicker.dataSource = self; | |
| 142 | + _effectPicker.delegate = self; | |
| 143 | + _effectPicker.hidden = YES; | |
| 144 | + } | |
| 145 | + return _effectPicker; | |
| 146 | +} | |
| 147 | + | |
| 148 | +- (UISegmentedControl *)filterGroupType | |
| 149 | +{ | |
| 150 | + if (!_filterGroupType) { | |
| 151 | + NSArray *items = @[ @"关", | |
| 152 | + @"旧美颜", | |
| 153 | + @"红润美颜", | |
| 154 | + @"美颜特效", | |
| 155 | + ]; | |
| 156 | + | |
| 157 | + _filterGroupType = [[UISegmentedControl alloc] initWithItems:items]; | |
| 158 | + _filterGroupType.frame = CGRectMake(10, 0, self.bounds.size.width-20, 30); | |
| 159 | + _filterGroupType.tintColor= [UIColor blackColor]; | |
| 160 | + _filterGroupType.selectedSegmentIndex = 0; | |
| 161 | + _filterGroupType.layer.cornerRadius = 5; | |
| 162 | + _filterGroupType.selectedSegmentIndex = 1; | |
| 163 | + [_filterGroupType addTarget:self action:@selector(onSegCtrl:) forControlEvents:UIControlEventValueChanged]; | |
| 164 | + } | |
| 165 | + return _filterGroupType; | |
| 166 | +} | |
| 167 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/SliderView.h
0 → 100755
| 1 | +// | |
| 2 | +// SliderView.h | |
| 3 | +// CNLivePlayerSDKDemo | |
| 4 | +// | |
| 5 | +// Created by iOS on 16/12/21. | |
| 6 | +// Copyright © 2016年 雷浩杰. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +@protocol SliderViewDelegate <NSObject> | |
| 12 | + | |
| 13 | +- (void)sliderValueChenged; | |
| 14 | + | |
| 15 | +@end | |
| 16 | + | |
| 17 | +@interface SliderView : UIView | |
| 18 | + | |
| 19 | +@property (nonatomic, strong) UILabel* nameL; // 滑块对应参数名称 | |
| 20 | +@property (nonatomic, strong) UISlider* slider; // 滑块 | |
| 21 | +@property (nonatomic, strong) UILabel* valueL; // 滑块当前的值 | |
| 22 | +@property (nonatomic, assign, readonly) float currentValue; | |
| 23 | +@property (nonatomic, assign) id<SliderViewDelegate> delagate; | |
| 24 | + | |
| 25 | +- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title; | |
| 26 | + | |
| 27 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/SliderView.m
0 → 100755
| 1 | +// | |
| 2 | +// SliderView.m | |
| 3 | +// CNLivePlayerSDKDemo | |
| 4 | +// | |
| 5 | +// Created by iOS on 16/12/21. | |
| 6 | +// Copyright © 2016年 雷浩杰. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "SliderView.h" | |
| 10 | + | |
| 11 | +@implementation SliderView | |
| 12 | +{ | |
| 13 | + NSString *_title; | |
| 14 | +} | |
| 15 | + | |
| 16 | +- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title{ | |
| 17 | + self = [super initWithFrame:frame]; | |
| 18 | + if (self) { | |
| 19 | + _title = title; | |
| 20 | + [self addSubview:self.nameL]; | |
| 21 | + [self addSubview:self.valueL]; | |
| 22 | + [self addSubview:self.slider]; | |
| 23 | + } | |
| 24 | + return self; | |
| 25 | +} | |
| 26 | + | |
| 27 | +- (float)currentValue | |
| 28 | +{ | |
| 29 | + return _slider.value; | |
| 30 | +} | |
| 31 | + | |
| 32 | +#pragma mark - | |
| 33 | +#pragma mark - action | |
| 34 | + | |
| 35 | +- (void)onSlider:(UISlider *)slider | |
| 36 | +{ | |
| 37 | + _valueL.text = [NSString stringWithFormat:@"%d",(int)(slider.value * 100)]; | |
| 38 | + if (self.delagate && [self.delagate respondsToSelector:@selector(sliderValueChenged)]) { | |
| 39 | + [self.delagate sliderValueChenged]; | |
| 40 | + } | |
| 41 | +} | |
| 42 | + | |
| 43 | +#pragma mark - | |
| 44 | +#pragma mark - getter | |
| 45 | + | |
| 46 | +- (UILabel *)nameL | |
| 47 | +{ | |
| 48 | + if (!_nameL) { | |
| 49 | + _nameL = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 24)]; | |
| 50 | + _nameL.text = _title; | |
| 51 | + _nameL.textAlignment = NSTextAlignmentCenter; | |
| 52 | + _nameL.textColor = [UIColor whiteColor]; | |
| 53 | + _nameL.backgroundColor = [UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1]; | |
| 54 | + _nameL.layer.cornerRadius = 5; | |
| 55 | + _nameL.layer.masksToBounds = YES; | |
| 56 | + } | |
| 57 | + return _nameL; | |
| 58 | +} | |
| 59 | + | |
| 60 | +- (UILabel *)valueL | |
| 61 | +{ | |
| 62 | + if (!_valueL) { | |
| 63 | + _valueL = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width-40, 0, 40, 24)]; | |
| 64 | + _valueL.text = @"50"; | |
| 65 | + _valueL.textAlignment = NSTextAlignmentCenter; | |
| 66 | + _valueL.textColor = [UIColor whiteColor]; | |
| 67 | + _valueL.backgroundColor = [UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1]; | |
| 68 | + _valueL.layer.cornerRadius = 5; | |
| 69 | + _valueL.layer.masksToBounds = YES; | |
| 70 | + | |
| 71 | + } | |
| 72 | + return _valueL; | |
| 73 | +} | |
| 74 | + | |
| 75 | +- (UISlider *)slider | |
| 76 | +{ | |
| 77 | + if (!_slider) { | |
| 78 | + _slider = [[UISlider alloc] initWithFrame:CGRectMake(40, 0, self.bounds.size.width-80, 24)]; | |
| 79 | + _slider.value = 0.5; | |
| 80 | + [_slider addTarget:self action:@selector(onSlider:) forControlEvents:UIControlEventValueChanged]; | |
| 81 | + } | |
| 82 | + return _slider; | |
| 83 | +} | |
| 84 | +@end | ... | ... |