码迷,mamicode.com
首页 > 移动开发 > 详细

iOS_23_undress Girl

时间:2014-08-26 13:49:26      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:ios   undressgirl   绘图   

最终效果图:

bubuko.com,布布扣








关键代码如下:



bubuko.com,布布扣

//
//  BeyondViewController.h
//  24_showGirl
//
//  Created by beyond on 14-8-26.
//  Copyright (c) 2014年 com.beyond. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BeyondViewController : UIViewController
@property (nonatomic,weak) IBOutlet UIImageView *clothes;
@end


//
//  BeyondViewController.m
//  24_showGirl
//
//  Created by beyond on 14-8-26.
//  Copyright (c) 2014年 com.beyond. All rights reserved.
//

#import "BeyondViewController.h"

@interface BeyondViewController ()
{
    BOOL canEarse;
}

@end

@implementation BeyondViewController
// 触摸开始
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
	UITouch *touch = [touches anyObject];
    // 如果触摸点落在ClothesImgView上面
	if([touch view]==_clothes)
	{
		canEarse = YES;
	}
	
}
// 触摸进行中
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
	UITouch *touch = [touches anyObject];
	if(canEarse)
	{
        // 获得触摸点的坐标
		CGPoint currentPoint = [touch locationInView:_clothes];
        // 开启上下文
		UIGraphicsBeginImageContext(self.clothes.frame.size);
        // 将原图画到上下文中,以便进行像素处理
		[_clothes.image drawInRect:_clothes.bounds];
        // 清除触摸点附近区域的一些像素
		CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(currentPoint.x, currentPoint.y, 30, 30));
        // 重新画上去
		_clothes.image = UIGraphicsGetImageFromCurrentImageContext();
        // 关闭上下文
		UIGraphicsEndImageContext();
	}
}
// 触摸结束
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
	canEarse = NO;
	
}
@end




iOS_23_undress Girl

标签:ios   undressgirl   绘图   

原文地址:http://blog.csdn.net/pre_eminent/article/details/38845297

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!