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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章