iOS - how do I only update my UIImage on the UIView - ios

I've got an UIImage on a UIView. Instead of redrawing the entire UIView, I just want to redraw that specific UIImage. How do I do that?

UIImage on a UIView is not possible. I Think you mean a UIImageView on a UIView.
You can send to the UIImageView...
[yourImageView setNeedsDisplay];

Related

UIImage position on screen/window/superview

I want to add a UIButton to the end of NSAttributedString. I was unable to do that as NSAttachment only takes a UIImage.
So, I've added a UIImage to NSAttributedString as attachment and saved its reference. Now i want to obtain the position of this UIImage on UIScreen, UIWindow or Superview to put a UIButton at the position of image. Is it possible?

Blur for different UIImages in same UITableViewCell

So in my custom UITableViewCell I have 4 different UIImageView's & for each UILongTapGestureRecognizer.
Table View Cells before adding images
After I add images and table looks like this :
Table View Cells after adding images
I need to be able to delete image after long tap gesture recognizer, when the chosen image blurs out and remove button is shown.
I've added the long press gesture recognizer method and while I understand that I need to apply blur to the chosen image and not the UIImageView itself, I dont seem to get how to pass the reference of the picked image to the cell so that I can apply the blur filter to the image.
Is delegate legitimate to use in this case?
In order to apply blur effect as you mentioned you need the image itself.
You can try something like this :)
UIImage *image = [yourImageView image];
UIImage *blurredImage = [UIImageEffects imageByApplyingBlurToImage:image withRadius:30 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
yourImageView.image = blurredImage;
You can get UIImageEffects apple file from here :)
https://developer.apple.com/library/ios/samplecode/UIImageEffects/Listings/UIImageEffects_main_m.html
Hope it helps :)

Get uiview section under uiimageview?

I have an UIView as background, and a UIImageView above it.
What I want to do is fill the UIImageView with the UIView section that is in the back (without the white border)
I tried cropping a snapshot of the background but it doesnt look good. there is always a difference.
Make the background UIView a subview of the UIImageView and then set the property of the UIImageView yourImageView.clipsToBounds = YES
Use CALayer mask. The mask will be the smaller image view, and will be assigned to the background view's mask property.

UIImageView subclass for circle icon in IB

I need to create a UIImageView subclass that cuts an image to a circle shape, and draws a border.
I set the image view and image in a storyboard.
The initWithCoder method of my subclass is called, but other methods, such as drawRect: and setImage: are not called (I set breakpoints in every method). And the image that appears is not cropped.
Why are drawRect: and setImage: are not called?
Why you don't use imageView.layer?
for example:
imageView.layer.cornerRadius = imageView.frame.size.height/2.0f; // for circle shape
imageView.layer.borderWidth = 3.0;
imageView.layer.borderColor;
imageView.clipsToBounds = YES;
P.S. I'm sorry that i write here, small reputation...

Overlaying UIView with an background image

Is it possible to overlay UIView with an image without using UIImageView from the Interface Builder?
If not, how would you accomplish the same in code?
From the UIView documentation:
Image-based backgrounds - For views that display relatively static content, consider using a UIImageView object with gesture recognizers instead of subclassing and drawing the image yourself. Alternatively, you can also use a generic UIView object and assign your image as the content of the view’s CALayer object.
Using the second option, to set someView to have a background of yourImage.png:
someView.layer.contents = (id)[[UIImage imageNamed:#"yourImage.png"] CGImage];
if by Overlying a UIView you mean painting its background with an image, it can be done like this:
someView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"yourImage.png"]];
You could also add a new UIImageView that covers your UIView
by code, Init your UIImageView with the same frame Rect as your UIView and add it as a subview.

Resources