0
비디오 앱을 만들고 있는데 비디오 배경을 흐리게 추가하려고합니다. like that 및 슬라이드 값에 따라 흐림 효과를 제어합니다. 나는 코딩을 위해 Objectivc-C를 사용하고있다. 어느 누구도 저를 어떻게해야합니까?iOS 비디오 배경 흐림 효과 만들기
당신은 단지 마스크 흐림보기를 필요비디오 앱을 만들고 있는데 비디오 배경을 흐리게 추가하려고합니다. like that 및 슬라이드 값에 따라 흐림 효과를 제어합니다. 나는 코딩을 위해 Objectivc-C를 사용하고있다. 어느 누구도 저를 어떻게해야합니까?iOS 비디오 배경 흐림 효과 만들기
당신은 단지 마스크 흐림보기를 필요,이 코드를 사용하려고 :
@interface ViewController()
@property UISlider *slider;
@property UIVisualEffectView *visualEffectView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//VisableRect = 100,100,200,200
//Add a backgroun picture
UIImageView* imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 100)];
imageV.image = [UIImage imageNamed:@"test"];
[self.view addSubview:imageV];
_visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
_visualEffectView.frame = imageV.frame;
_visualEffectView.alpha = 1.0;
[self.view addSubview:_visualEffectView];
//create path
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:imageV.bounds];
UIBezierPath *otherPath = [[UIBezierPath bezierPathWithRect:CGRectMake(100, 100, 200, 200)] bezierPathByReversingPath];
[maskPath appendPath:otherPath];
//set mask
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = maskPath.CGPath;
[_visualEffectView.layer setMask:maskLayer];
_slider = [[UISlider alloc] initWithFrame:CGRectMake(0, imageV.frame.size.height, 200, 20)];
_slider.minimumValue = 0;
_slider.maximumValue = 1;
_slider.value = 1;
[_slider addTarget:self action:@selector(updateValue:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:_slider];
}
-(IBAction)updateValue:(id)sender{
float sVaLue = _slider.value;
_visualEffectView.alpha = sVaLue;
}
및 효과는이 그림 같다 :
당신은에 마스크 층의 경로를 변경할 수 있습니다 원하는 모양을 선택하고 비디오를 흐리게 처리해야한다면 원하는 이미지로 V를 변경하면됩니다.
희망이 있으면 도움을 드리겠습니다.
답장을 보내 주셔서 감사합니다. – Rupshikha
아직 몇 가지 문제가 있습니까? @Rupshikha –
아직 시도하지 않았습니다. 재생할 때 비디오 프레임에 따라 동적 흐림 효과가 필요합니다. 문제가 생기면 알려 드리겠습니다. – Rupshikha