Tag: uiimage

iOS:从url加载图片

我需要从一个URL加载图像,并将其设置在一个UIImageView; 问题是我不知道图像的确切大小,那么我怎样才能正确地显示图像?

UITableViewCell中UIImage的默认大小是多less?

我想在UITableView的每一行的左侧放置一个UIImage。 这是非常标准的,并直接由UIKit支持。 但是,(大)形象造成了各种各样的尴尬,所以我想我应该正确地扩大自己的东西。 但是没有一个文档使用标准的开箱视图给出了这个图像的默认尺寸 – 我很惊讶。 SO上的其他人指出,44是行的默认高度(UITableViewCell的默认高度是多less? )44×44是“默认”图像大小? 谢谢!

UIImage的Swift游乐场

我正在使用Xcode 6,并且正在尝试在会话401“Xcode 6中的新增function”中重新演示代码。 我已经添加了Images.xcassets图像(称为示例),并在操场文件中试图访问此图像,演示。 我的代码如下(如演示): var sample = UIImage(named: "Sample") 但是,我不能像演示一样工作。 我错过了什么吗?

如何在UIImageView中显示base64图像?

我有这个Base64 gif图像: R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7 现在我想在我的iPhone应用程序中显示这个Base64string。 我可以通过使用WebView来实现这个工作: aUIWebView.scalesPageToFit = NO; aUIWebView.opaque = NO; aUIWebView.backgroundColor = [UIColor clearColor]; [aUIWebView loadHTMLString: @"<html><body style=""background-color: transparent""><img src=""data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7"" /></body></html>" baseURL:nil]; 是否有可能通过使用UIImageView做同样的事情?

如何绘制UIImage或直接在-drawRect中:?

我有一个UIImage ,我想在UIView上绘制。 但是,而不是创build一个UIImageView并将其添加为子视图,我想覆盖-drawRect:并直接绘制我的UIView。 例如,我的代码如下所示: – (void)drawRect:(CGRect)rect { CGContextRef myContext = UIGraphicsGetCurrentContext(); UIImage *img = [UIImage imageNamed:@"foo.png"]; // how to draw the directly into the view now? }

UIImageresize(缩放比例)

可能重复: 调整高宽比UIImage? 下面的一段代码是完美的调整图像的大小,但问题是,它会扰乱纵横比(导致图像偏斜)。 任何指针? // Change image resolution (auto-resize to fit) + (UIImage *)scaleImage:(UIImage*)image toResolution:(int)resolution { CGImageRef imgRef = [image CGImage]; CGFloat width = CGImageGetWidth(imgRef); CGFloat height = CGImageGetHeight(imgRef); CGRect bounds = CGRectMake(0, 0, width, height); //if already at the minimum resolution, return the orginal image, otherwise scale if (width <= resolution && height <= […]

在iOS中使用URL创buildUIImage

要创build一个图像文件的UiImage,我使用如下代码: UIImage *aImage = [[UIImage imageNamed:@"demo.jpg"]autorelease]; 如果我想用URL http://example.com/demo.jpg创build一个UiImage,该怎么做? 谢谢 UPDATE

如何在Objective-C中创build一个空白的透明PNG?

如何在Objective C中以编程方式创build一个空白png UIImage(比方说36×36像素)? 谢谢 :)

更改UIImage颜色

我正在尝试改变UIImage的颜色。 我的代码: -(UIImage *)coloredImage:(UIImage *)firstImage withColor:(UIColor *)color { UIGraphicsBeginImageContext(firstImage.size); CGContextRef context = UIGraphicsGetCurrentContext(); [color setFill]; CGContextTranslateCTM(context, 0, firstImage.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextSetBlendMode(context, kCGBlendModeCopy); CGRect rect = CGRectMake(0, 0, firstImage.size.width, firstImage.size.height); CGContextDrawImage(context, rect, firstImage.CGImage); CGContextClipToMask(context, rect, firstImage.CGImage); CGContextAddRect(context, rect); CGContextDrawPath(context,kCGPathElementMoveToPoint); UIImage *coloredImg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return coloredImg; } 此代码工作,但获得的图像是不是应该如此:返回的图像的边界像素是间歇性的,不像我的第一个图像那么光滑。 我该如何解决这个问题?

如何将UIImage转换为CIImage,反之亦然

我试图从屏幕上显示的ImageView中获取CIImage 。 UIImage *image = myImageView.image; 将图像UIImage转换为CIImage 。 CIImage *cImage = [….]; 这个怎么做?