uiimageview

Setting content mode for something besides UIImageView in iOS

寵の児 提交于 2019-12-11 03:36:02
问题 This answer shows the various effects of setting the content mode of a UIImageView . Since UIView also has a content mode setting in the Interface Builder, I want to know why setting it doesn't affect any subviews that are in it. Here is an example that I tried. The blue view is a UIView and the yellow view is a UILabel . But if I set the mode to Top for the UIView , the label just stays in the same place. Does content mode only work for UIImageViews ? If it doesn't work for UIViews , why is

snapshotViewAfterScreenUpdates creating a blank image

时光总嘲笑我的痴心妄想 提交于 2019-12-11 02:58:15
问题 I'm trying to create some composite UIImage objects with this code: someImageView.image = [ImageMaker coolImage]; ImageMaker: - (UIImage*)coolImage { UIView *composite = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]; UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"coolImage"]]; //This is a valid image - can be viewed when debugger stops here [composite addSubview:imgView]; UIView *snapshotView = [composite snapshotViewAfterScreenUpdates:YES]; //at

Creating object programmatically and changing that object's position

≡放荡痞女 提交于 2019-12-11 02:55:12
问题 I am trying to create a couple of UIImageViews (preferably with a for loop) and then afterwards move them, but I don't know how because I'm having trouble figuring out how to reference them if they will be made programmatically. So I want something like this: for (int i = 0; i < 2; i++) { UIImageView *iv = [[UIImageView alloc]initWithImage:[UIImage imageNamed: picturo]]; CGRect rect = CGRectMake((i * 50) + 50,30, 25, 25); [iv setFrame:rect]; iv.tag = i; [self.view addSubview:iv]; } (iv with

UIImageView in table view not showing until clicked on or device is roatated

别说谁变了你拦得住时间么 提交于 2019-12-11 02:47:23
问题 I am in the process of learning swift/IOS and having a problem with getting an image to display in a table view cell when the imageView is set within a closure passed to dispatch_async(dispatch_get_main_que) . Here is my code for returning the cell for the tableview. Notice that the dispatch calls are commented out. In this state everything is OK. (the image is displayed with out any interaction) override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) ->

Adding UIImage ignores and resizes UIImageView frame

前提是你 提交于 2019-12-11 02:33:41
问题 I'm currently trying to add an image into the navigation item for one view. In the view's viewDidLoad() , a function is called with the following code, similar to this post: let logo = UIImage(named: "Menu_Logo") let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 122, height: 26)) imageView.contentMode = .scaleAspectFit imageView.clipsToBounds = true imageView.image = logo self.navigationItem.titleView = imageView Instead of giving me the expected size however, the view ends up

Image in UIButton is darker tharn original

别等时光非礼了梦想. 提交于 2019-12-11 02:03:13
问题 I'm trying to add a UIButton in a cell which already has a UIImageView in the background. I put this code in configureCell UIButton *mail = [[UIButton alloc] initWithFrame:CGRectMake(10, 270, 40, 40)]; [mail setImage:[UIImage imageNamed:@"mail.png"] forState:UIControlStateNormal]; mail.backgroundColor = [UIColor whiteColor]; [mail addTarget:self action:@selector(sendMail) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:mail]; It works but the image in the UIButton

For swaths of color, which is cheaper: UIView or UIImage

被刻印的时光 ゝ 提交于 2019-12-11 01:57:14
问题 Suppose in your UI design, you need a rectangle of solid color. Of course you could use a UIImageView object and hook it up to an image, but in some cases it might be quicker and easier to just drop in a UIView and set the background color. My question is with regard to which is cheaper in terms of memory and performance. My gut is that an empty UIView is easier to render than an image, whose file must be loaded and bits stored in memory. Can anyone speak to this? Many thanks! 回答1: Setting

Crop and save visible region of UIImageView using AspectFill

◇◆丶佛笑我妖孽 提交于 2019-12-11 01:49:56
问题 I have a fullscreen UIImageView with a image in it set to AspectFill (full bleed), how can I save only the visible portion of the image when its using the Aspect Fill content mode? CGRect visibleRect; visibleRect.size= mImageView.frame.size; CGImageRef cropped_img = CGImageCreateWithImageInRect(mImageView.image.CGImage, visibleRect); UIImage *finalImage = [[UIImage alloc]initWithCGImage:cropped_img]; UIImageWriteToSavedPhotosAlbum(finalImage, nil, nil, nil); This is my current code, cropping

“Cannot assign to property: ”any“ is immutable” error

给你一囗甜甜゛ 提交于 2019-12-11 01:45:04
问题 tiledViewsStack contains UIImageViews. I'm trying to give each UIImageView in the array a new center coordinate. Not sure why I'm getting this error for the last line in the for loop... var tiledViewsStack = [AnyObject]() var randLocInt = Int() var randLoc = CGPoint() for var any in tiledViewsStack { randLocInt = Int((arc4random()*10) % 9) // 0, --- 8 randLoc = allCenters[randLocInt].CGPointValue() any.center = randLoc } 回答1: Needed to make tiledViewsStack a stack of UIImages, not AnyObjects.

How to update NSLayoutConstraint in a UITableViewCell of dynamic height?

被刻印的时光 ゝ 提交于 2019-12-11 01:28:30
问题 A UITableViewCell contains an UIImageView and has the height UITableViewAutomaticDimension . I want to resize the image view according to the size of its image. The image view should then resize the height of the table view cell. The vertical layout constraints of the image view in Interface Builder are: imageView.topAnchor = cell.contentView.topAnchor imageView.bottomAnchor <= cell.contentView.bottomAnchor + 10 imageView.heightAnchor = 100 I've set a layout constraint as IBOutlet for the