Iphone 如何实现图像周围的帧

Iphone 如何实现图像周围的帧,iphone,image-processing,uiimage,Iphone,Image Processing,Uiimage,我喜欢这样(http://shakeitphoto.com/)应用程序在图像周围放置边框。。我想在我的应用程序中做一些类似的事情,但不确定应该如何做 有没有关于如何在给定的UIImage周围环绕一个框架的想法?从该网站上看,您似乎想要一个带阴影的边框。有2个合理的选择,3个如果你不在乎阴影 如果你不在乎阴影,你可以做一些类似的事情 #import <QuartzCore/QuartzCore.h> // this should be at the top // inside you

我喜欢这样(http://shakeitphoto.com/)应用程序在图像周围放置边框。。我想在我的应用程序中做一些类似的事情,但不确定应该如何做


有没有关于如何在给定的UIImage周围环绕一个框架的想法?

从该网站上看,您似乎想要一个带阴影的边框。有2个合理的选择,3个如果你不在乎阴影

如果你不在乎阴影,你可以做一些类似的事情

#import <QuartzCore/QuartzCore.h> // this should be at the top

// inside your view layout code
myImageView.layer.borderColor = [UIColor whiteColor].CGColor
myImageView.layer.borderWidth = 5;

(注意:此代码尚未编译,可能包含bug)

如果您希望人们查看某些内容,请发布屏幕。没有人会下载一个应用程序只是为了看看问题是关于什么的。编辑:另外,关于堆栈溢出,已经有很多问题了。看看其中的一些。
- (UIImage *)borderedImage:(UIImage *)image {
    // the following NO means the new image has an alpha channel
    // If you know the source image is fully-opaque, you may want to set that to YES
    UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
    [image drawAtPoint:CGPointZero];
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    const CGFloat shadowRadius = 5;
    CGContextSetShadowWithColor(ctx, 0, shadowRadius, [UIColor blackColor].CGColor);
    [[UIColor whiteColor] set];
    CGRect rect = (CGRect){CGPointZero, image.size};
    const CGFloat frameWidth = 5;
    rect = CGRectInset(rect, frameWidth / 2.0f, frameWidth / 2.0f);
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:rect];
    path.lineWidth = frameWidth;
    [path stroke];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    // note: getting the new image this way throws away the orientation data from the original
    // You could create a third image by doing something like
    //   newImage = [UIImage imageWithCGImage:newImage.CGImage scale:newImage.scale orientation:image.orientation]
    // but I am unsure as to how orientation actually affects rendering (if at all)
    UIGraphicsEndImageContext();
    return newImage;
}