从屏幕截取一块区域,将其赋给imageView

UIGraphicsBeginImageContext(self.bounds.size);

                [self.layerrenderInContext:UIGraphicsGetCurrentContext()];

                UIImage *cardImage = UIGraphicsGetImageFromCurrentImageContext();

                if (self.card == nil) {

                    self.card = [[UIImageView alloc] initWithImage:cardImage];

                }

                else

                {

                    self.card.image = cardImage;

                }

            }

            self.card.center = [touch locationInView:self];

            [self addSubview:self.card];

            UIGraphicsEndImageContext();

            self.layer.contents = nil;

posted on 2013-12-03 23:17  IOS开发者  阅读(220)  评论(0编辑  收藏  举报