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

#import "AppDelegate.h"

#import "FeelHapplyVC.h"

@interface AppDelegate ()


@end


@implementation AppDelegate



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

   

    //设置根控制器

    FeelHapplyVC *vcFeelHapp = [[FeelHapplyVC alloc] 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 {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

    

    //更换背景颜色

    [[self view] setBackgroundColor:[UIColor grayColor]];

    

    //添加背景图片视图

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

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

    [bg_imageView setContentMode:UIViewContentModeScaleToFill];

    [self.view addSubview:bg_imageView];

    

    //设置覆盖view视图

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

    [mainView setBackgroundColor:[UIColor clearColor]];


    //被覆盖区域视图

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

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

    testTV.textColor = [UIColor whiteColor];

    testTV.backgroundColor = [UIColor orangeColor];

    [self.view addSubview:testTV];

    

    //遮挡的imageview

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

    [imageView setBackgroundColor:[UIColor clearColor]];

    [imageView setContentMode:UIViewContentModeScaleToFill];

    [imageView setImage:[UIImage imageNamed:@"95C2B035D"]];

    [mainView addSubview:imageView];

    

    _scratchView = [[STScratchView alloc] init];

    [_scratchView setContentMode:UIViewContentModeScaleAspectFit];

    [_scratchView setFrame:self.view.bounds];

    [_scratchView setBackgroundColor:[UIColor clearColor]];

    [_scratchView setSizeBrush:30.0];

    [mainView addSubview:imageView];

    [_scratchView setHideView:mainView];

    [[self view] addSubview:_scratchView];

    

}



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



 


发布了10 篇原创文章 · 获赞 1 · 访问量 3万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章