图片滤镜iOS类库:FeSlideFilter

分享到:
用很生动的方式实现图片滤镜的选择过程。一般的图像加工类app,图像滤 镜的选择都是通过弹出一排滤镜效果(通常是默认图片的滤镜效果)让用户点击,然后再生成对应的图像效果。这份代码实现的滤镜选择过程是,直接在原图产生滤 镜效果,用户通过滑动屏幕,滤镜效果类似蒙版一样盖住原图,十分方便用户浏览不同的滤镜效果。  图片滤镜iOS类库:FeSlideFilter

Requirement

FeSpringFlowLayout use UIKit Dynamics to implement.

So You must ensure your project has iOS version more than iOS 7.0.

And compatible with ARC or non-ARC.

Sample code

In Sample code, I user LUT technique to apply filter to photo.

More info, visist my blog : http://nghiatran.me/index.php/filter-me-color-lookup-table-part-2/

If you wanna use LUT, please sure you added Core Image and OpenGL ES framwork to your project.

How to use

FeSlideFilter use Data Source / Delgate pattern like UITableView.

Just provide filtered UIImage

and Title for each Filter.

Ex :

// Number of filter
-(NSInteger) numberOfFilter
{
return 5;
}
// Title for filter at index
-(NSString *) FeSlideFilterView:(FeSlideFilterView *)sender titleFilterAtIndex:(NSInteger)index
{
return _arrTittleFilter[index];
}
// Filtered UIImage at index
-(UIImage *) FeSlideFilterView:(FeSlideFilterView *)sender imageFilterAtIndex:(NSInteger)index
{
return _arrPhoto[index];
}

If you want to customize by yourself. Just assign your button with _doneBtn property.

// Btn
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(0, 0, 40, 40);
[btn setBackgroundImage:[UIImage imageNamed:@"done"] forState:UIControlStateNormal];
_slideFilterView.doneBtn = btn;

Data Source - Delegate

You can change behavior by changing 3 properties when init

Data Source :

@required
// Number of filter
-(NSInteger) numberOfFilter;
// Title filter at index
-(NSString *) FeSlideFilterView:(FeSlideFilterView *) sender titleFilterAtIndex:(NSInteger) index;
// Image at index
-(UIImage *) FeSlideFilterView:(FeSlideFilterView *) sender imageFilterAtIndex:(NSInteger) index;
@optional
// Font at index
-(UIFont *) FeSlideFilterView:(FeSlideFilterView *) sender fontForTitleAtIndex:(NSInteger) index;
// Layer's content Gravity
-(NSString *) kCAContentGravityForLayer;

Delegate :

// Call when user tapped Btn
-(void) FeSlideFilterView:(FeSlideFilterView *) sender didTapDoneButtonAtIndex:(NSInteger) index;
// Determine when user can slide
-(BOOL) FeSlideFilterView:(FeSlideFilterView *)sender shouldSlideFilterAtIndex:(NSInteger) index;
// Call when user have just slided
-(void) FeSlideFilterView:(FeSlideFilterView *)sender didBeginSlideFilterAtIndex:(NSInteger) index;
// Call when user end Slide
-(void) FeSlideFilterView:(FeSlideFilterView *)sender didEndSlideFilterAtIndex:(NSInteger) index;

MIT License

项目主页:http://www.open-open.com/lib/view/home/1413862566950

昵    称:
验证码:

相关文档: