我的代码适用于普通设备,但在视网膜设备上会产生模糊图像.
有人知道我的问题的解决方案吗?
+ (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Run Code Online (Sandbox Code Playgroud) 我没有在Sprite Kit中找到任何支持Drophadow或字体轮廓的内容.对于Drophadow,我猜我可以创建第二个SKLabelNode并将其偏移到另一个之后.
有没有什么方法可以使用SKEffectNode作为轮廓或阴影?可能使SKLabelNode成为SKEffectNode的子代?
更新:
我能够使用第一个后面的第二个SKLabelNode得到一个不错的阴影,即黑色和偏移.仍然对其他潜在的选择感兴趣,但这似乎运作良好.
我需要从UITextView或UILabel中获取UIImage.我有一个方法可以从其他类型的视图([UIViewController视图],MKMapView,UIButtons)成功地提取图像,但我只是为我的UITextView获取一个白色矩形.
我一直在靠墙撞墙,并怀疑一些非常非常基本的东西.
非常感谢!
@interface TaskAccomplishmentViewController : UIViewController {
MKMapView *mapView;
UILabel *timeLeftText;
UITextView *challengeText;
UIButton *successButton;
<snip>
- (void) setChallangeImageToImageFromChallenge {
// works
// [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:mapView]];
// [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:[self view]]];
// [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:successButton]];
// doesn't work
// [currChallenge setChallengeImage:[UIImageUtils grabImageFromView:timeLeftText]];
[currChallenge setChallengeImage:[UIImageUtils grabImageFromView:challengeText]];
}
Run Code Online (Sandbox Code Playgroud)
和来自UIView代码的grabImage
+(UIImage *)grabImageFromView: (UIView *) viewToGrab {
UIGraphicsBeginImageContext(viewToGrab.bounds.size);
[[viewToGrab layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
Run Code Online (Sandbox Code Playgroud)