uiimageview

How to compare UIColors?

落爺英雄遲暮 提交于 2019-12-17 02:29:32
问题 I'd like to check the color set for a background on a UIImageView. I've tried: if(myimage.backgroundColor == [UIColor greenColor]){ ...} else{ ...} but that doesn't work, even when I know the color is green, it always falls into the else part. Also, is there a way to output the current color in the debug console. p [myimage backgroundColor] and po [myimage backgroundColor] don't work. 回答1: Have you tried [myColor isEqual:someOtherColor] ? 回答2: As zoul pointed out in the comments, isEqual:

Fade/dissolve when changing UIImageView's image

风流意气都作罢 提交于 2019-12-17 02:25:42
问题 Rather than creating two UIImageViews , it seems logical to simply change the image of one view. If I do that, is there anyway of having a fade/cross dissolve between the two images rather than an instant switch? 回答1: Edit: there is a better solution from @algal below. Another way to do this is by using predefined CAAnimation transitions: CATransition *transition = [CATransition animation]; transition.duration = 0.25; transition.timingFunction = [CAMediaTimingFunction functionWithName

How to write text on image in Objective-C (iOS)?

给你一囗甜甜゛ 提交于 2019-12-17 01:34:12
问题 I want to make an image like this programmatically: I have the upper image and text with me. Should I write text on the image? I want to make it a complete .png image(image + label) and set it as the background of the button. 回答1: Draw text inside an image and return the resulting image: +(UIImage*) drawText:(NSString*) text inImage:(UIImage*) image atPoint:(CGPoint) point { UIFont *font = [UIFont boldSystemFontOfSize:12]; UIGraphicsBeginImageContext(image.size); [image drawInRect:CGRectMake

Move UIImage only inside of another UIImage

冷暖自知 提交于 2019-12-14 03:52:38
问题 I have an UIImage which is shown in an UIImageView . I also have another image in an UIImageView which lays above the first image. I want to be able to drag the second image only within the borders of the first image. To make my goal a bit more clearer look at this image: . The green pin should be dragable but it should not be possible to drag the pin into the blue (outside of the map). At the moment the pin is dragable, but I don't know how to check if the pin is outside of the map. EDIT: I

Easy Asynchronous Image Download UIImage View

Deadly 提交于 2019-12-14 02:34:47
问题 I have an app i am building it works fine but the image source i am using is from a website and when I switch back to my initial view it takes quite some time for it to load. My question is would there be a way to get this done and have the speed be faster. here is the code I use to pull my image source ////Loads UIImageView from URL todaysWallpaper.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.inkdryercreative.com/daily/archive/mondays/images

Image loads in simulator but not device?

一世执手 提交于 2019-12-14 01:43:40
问题 In Interface Builder, I have a UIImageView in a nib and have selected an image from the View Attributes pane. The image loads fine in the simulator but not on my device in debug mode. I don't get any errors. Just no image. I can see the particular image in my Target's Copy Bundle Resources folder. Any ideas why it isn't showing on the device? 回答1: A possible cause: Iphone file system is case sensitive and MacOS is not. Try to check your image file name. 来源: https://stackoverflow.com/questions

Add a subview to a UIImageView that is the view outlet of a UIViewController in IB

女生的网名这么多〃 提交于 2019-12-14 01:19:52
问题 I have a UIViewController object in a .xib file. I add a UIImageView to it, and then try to add a button as a subview of the UIImageView. It instead replaces the UIImageView. It works fine if both are subviews of a UIView. What gives? I thought this would work since UIImageView is a subclass of UIView? 回答1: Only Apple knows. However, look at here for a workaround: Apple Interface Builder: adding subview to UIImageView 回答2: A UIImageView is it's own object and a UIButton is its own object. A

CIImage filter is stretching my image vertically

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-14 00:42:38
问题 I have an image which I'm using in a custom UITableViewCell . The image is a black triangle on a transparent background and I'm using a CIColorInvert filter to make it a white triangle on a transparent background. The filtered (inverted) image is being stretched vertically, how can I stop this from happening? If I load the UIImage directly without doing the filtering what I get is this: If I apply the CIFilter what I get is this: Here's my code: // create the white triangle CIImage

UIButton not calling event in imageView

微笑、不失礼 提交于 2019-12-13 22:58:01
问题 I have imageview in which I am adding UIButton it shows button when I click on button it does not call the action of the button. Here is the code I am using I have also set the imageView.userInteraction=enabled but still it is not calling the action. UIImageView*myImageView=[[UIImageView alloc] initWithFrame:CGRectMake(75,10,200,150)]; myImageView.image=thumbnail; myImageView.userInteractionEnabled=YES; [scrollView addSubview:myImageView]; UIButton*playButton=[[UIButton alloc] initWithFrame

Change UIBarButton image from gallery

ぃ、小莉子 提交于 2019-12-13 22:19:25
问题 I have UIBarButton and user can change image just chose photo or gallery image with image picker. My problem is bad scale image. If I use AspectFit my UIBarButton look like this: If I use AspectFill my UIBarButton look like this: and if I try first change size image and after set it, image all time scratched: This is my code: func createPhotoBarButton(image: Data) { let barbtn = UIBarButtonItem() var image = UIImage(data:image) if image == nil { image = UIImage(named: "photoIcon") } let