uiimageview

How to resize an UIImageView (swift)

冷暖自知 提交于 2019-12-18 17:30:44
问题 I'm a beginner with swift and I can't get the resize of a UIImageView working. Here is my current layout : What I want is to resize the images to occupy half the screen's width (2 images per row). Here is my storyboard : Here is the function drawing the collection view inside my controller : func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! { var cell : MenuInspirationCellView = collectionView

How to add UIImageView in UIAlertController?

蹲街弑〆低调 提交于 2019-12-18 16:45:49
问题 I want UIAlertController to present an alert with UIImageView in an ActionSheet . But when I run the application it is terminating. This is my code: UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title" message:@"Welcome" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okButton = [UIAlertAction actionWithTitle:OK style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { }]; [alert addAction:okButton]; UIImageView *imgv = [[UIImageView alloc

UIImageView scaling/interpolation

左心房为你撑大大i 提交于 2019-12-18 14:59:12
问题 I have a small IPhone app that I am working on and I am displaying an image with a UIImageView. I am scaling it up using the Aspect Fit mode. I would like to have the image scale up with no interpolation/smoothing (I want it to look pixellated). Is there any way I can change this behavior? A little more general question would be can I implement my own scaling algorithm, or are there other built in ones that I can select? 回答1: You would need to set the magnificationFilter property on the view

how to get width and height of image from url without downloading?

别等时光非礼了梦想. 提交于 2019-12-18 12:58:26
问题 I'm using SDWebImage for showing images inside cells. But it is perfect mached to frame of UImageView that I'm doing in code below: NSString * s =[NSString stringWithFormat:@"url of image to show"]; NSURL *url = [NSURL URLWithString:s]; [cell.shopImageView sd_setImageWithURL:url]; My UIImageView is size 50x50. For example image from url is size 990x2100 and my image is not displaying well in the frame given. In this case when hight is bigger, I want to resize my image by proper height ratio

Image is not fit to the frame of UIImageView

ぐ巨炮叔叔 提交于 2019-12-18 12:57:16
问题 I am creating the UIImageView using interface Builder. Its frame size is (320,67). I want to display the image on the imageView. I am getting the image from the web. The problem is that the image get from web is stretched to display on the imageview... Here my code NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.isco.com/webproductimages/appBnr/bnr1.jpg"]]; imageView.image = [UIImage imageWithData:imageData]; Can anyone tel me that how to display the image

How to mask the layer of a view by the content of another view?

心已入冬 提交于 2019-12-18 12:47:40
问题 I have a UIImageView and a UILabel, and want the content of the UILabel to mask the UIImageView. The goal is that the text is visible with content of image but everything else transparent. Is there a simple way to mask a view by the contents of another view? 回答1: You can use QuartzCore Framework . (Link project with QuartzCore.framework and import <QuartzCore/QuartzCore.h>). @import QuartzCore; Background of label must be clear color. Example: self.imageView.layer.mask = self.label.layer;

UIImageView is disappearing after CAKeyframeAnimation

守給你的承諾、 提交于 2019-12-18 12:38:34
问题 I'm trying this code (found in an answer here on SO) in a category on UIView and am using it to peform a "pop" animation on a UIImageView nested inside of a UITableViewCell. - (void)attachPopUpAnimation { CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; CATransform3D scale1 = CATransform3DMakeScale(0.5, 0.5, 1); CATransform3D scale2 = CATransform3DMakeScale(1.2, 1.2, 1); CATransform3D scale3 = CATransform3DMakeScale(0.9, 0.9, 1); CATransform3D scale4 =

create UIImageView with portion of image file

。_饼干妹妹 提交于 2019-12-18 12:38:17
问题 I'm subclassing UIImageView to create a tile-based application. Essentially, I am taking a single image file and breaking it up into pieces, and then assigning the pieces to my tiles ( UIImageViews ), so that they can be manipulated independently. What's the best way to grab a portion of an image and use that to draw a UIImageView ? I thought about overriding drawRect and using CGAffineTransform , but it seems like there ought to be a simpler way to do this, perhaps by specifying a CGRect to

create UIImageView with portion of image file

喜夏-厌秋 提交于 2019-12-18 12:38:08
问题 I'm subclassing UIImageView to create a tile-based application. Essentially, I am taking a single image file and breaking it up into pieces, and then assigning the pieces to my tiles ( UIImageViews ), so that they can be manipulated independently. What's the best way to grab a portion of an image and use that to draw a UIImageView ? I thought about overriding drawRect and using CGAffineTransform , but it seems like there ought to be a simpler way to do this, perhaps by specifying a CGRect to

Draw border around content of UIImageView

自作多情 提交于 2019-12-18 12:34:25
问题 I've a UIImageView with a image with is a car with a transparent background: And I want to draw a border around the car: How can I reach this effect? At the moment, I've tested CoreGraphics in this way, but without good results: // load the image UIImage *img = carImage; UIGraphicsBeginImageContext(img.size); CGContextRef context = UIGraphicsGetCurrentContext(); [[UIColor redColor] setFill]; CGContextTranslateCTM(context, 0, img.size.height); CGContextScaleCTM(context, 1.0, -1.0);