zoukankan      html  css  js  c++  java
  • iOS_23_undress Girl

    最后效果图:









    关键代码例如以下:




    //
    //  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
    




    版权声明:本文博客原创文章。博客,未经同意,不得转载。

  • 相关阅读:
    4 行代码实现将文件读到 C++ string
    Adaptive AUTOSAR 学习笔记 15
    Adaptive AUTOSAR 学习笔记 14
    Adaptive AUTOSAR 学习笔记 13
    Adaptive AUTOSAR 学习笔记 12
    Adaptive AUTOSAR 学习笔记 10
    Adaptive AUTOSAR 学习笔记 9
    Linux 彻底卸载从源码安装的 boost 库
    Adaptive AUTOSAR 学习笔记 8
    grep awk sed 正则表达式,只把匹配的内容(不是整个匹配行)提取出来,保存到 shell 脚本变量
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4690342.html
Copyright © 2011-2022 走看看