iOS 实现刮刮乐效果demo剑客篇(欢迎提建议和分享经验)

来源:互联网 发布:阿里巴巴美工招聘 编辑:程序博客网 时间:2024/06/07 12:40

#import "AppDelegate.h"

#import "FeelHapplyVC.h"

@interface AppDelegate ()


@end


@implementation AppDelegate



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

   

    //设置根控制器

   FeelHapplyVC *vcFeelHapp = [[FeelHapplyVCalloc] init];

   self.window.rootViewController = vcFeelHapp;

    

    // Override point for customization after application launch.

    return YES;

}




#import "FeelHapplyVC.h"

#import "STScratchView.h"

@interface FeelHapplyVC ()

@property (nonatomic,strong) STScratchView *scratchView;

@end


@implementation FeelHapplyVC


- (void)viewDidLoad {

    [superviewDidLoad];

    // Do any additional setup after loading the view.

    

    //更换背景颜色

    [[selfview] setBackgroundColor:[UIColorgrayColor]];

    

    //添加背景图片视图

    UIImageView *bg_imageView = [[UIImageViewalloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height)];

    bg_imageView.image = [UIImageimageNamed:@"asdfjogin.jpg"];

    [bg_imageView setContentMode:UIViewContentModeScaleToFill];

    [self.viewaddSubview:bg_imageView];

    

    //设置覆盖view视图

   UIView *mainView = [[UIViewalloc] initWithFrame:self.view.bounds];

    [mainView setBackgroundColor:[UIColorclearColor]];


    //被覆盖区域视图

    UITextView *testTV = [[UITextViewalloc] initWithFrame:CGRectMake(self.view.bounds.size.width - 150, 48, 138,433)];

    testTV.text =@"我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!我被挡住了,快来解救我!!";

    testTV.textColor = [UIColorwhiteColor];

    testTV.backgroundColor = [UIColororangeColor];

    [self.viewaddSubview:testTV];

    

    //遮挡的imageview

   UIImageView *imageView = [[UIImageViewalloc] initWithFrame:CGRectMake(self.view.bounds.size.width - 150, 48,138, 433)];

    [imageView setBackgroundColor:[UIColorclearColor]];

    [imageView setContentMode:UIViewContentModeScaleToFill];

    [imageViewsetImage:[UIImageimageNamed:@"95C2B035D"]];

    [mainViewaddSubview:imageView];

    

    _scratchView = [[STScratchViewalloc] init];

    [_scratchViewsetContentMode:UIViewContentModeScaleAspectFit];

    [_scratchView setFrame:self.view.bounds];

    [_scratchViewsetBackgroundColor:[UIColorclearColor]];

    [_scratchView setSizeBrush:30.0];

    [mainViewaddSubview:imageView];

    [_scratchViewsetHideView:mainView];

    [[selfview] addSubview:_scratchView];

    

}



DEMO免费下载地址:http://download.csdn.net/detail/u012113447/8260365



 


0 0
原创粉丝点击