/** * 这个尽管非常easy,算是一个小技巧,可是碰到了就记录下来吧.积跬步,致千里嘛. */ - (void)scratchableLatex { for (int i=0; i<9; i++) { UIView *view = [[UIView alloc]initWithFrame:CGRectMake(i%3*100+50, i/3*100+50, 50, 50)]; /* 当然为了区分,能够使用随机色 */ view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1]; [self.view addSubview:view]; } }