您的位置:首页 > 移动开发 > IOS开发

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

2014-12-15 10:03 423 查看
#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐