Desaturate colors in views below a UIView - ios

Is it possible to set a backgrounds image such that the views drawn below it are desaturated, rather than just darkened or tinted via a normal alpha value.
I do not have the ability to alter the views below, so it must be contained to the UIView or layer.
Thanks!

Sure, just overlay the view with a screenshot (How Do I Take a Screen Shot of a UIView?) and desaturate (ios sdk desaturate image).
Then you can display other viewcontroller modally with transparent background to see-through your desaturated image (iOS: Modal ViewController with transparent background).

Related

Can we hide a UIView partially in iOS

I have to partially hide a UIView when user scrolls over it. There is a UIScrollView above UIView.
For example in the given image below i want to hide the area covered under the scrollable area which is in blue color. All my views background colors are clear color.
I want to hide the part as given in the below image, the marked rectangle which is in red color. So that part of text (One, Two, Three) is only visible.
Each UIView, including UIScrollView, has a Core Animation Layer (a CALayer).
You access the CALayer with
view.layer
In turn, a CALayer has a mask, which you access with
layer.mask
Using the mask is the most comprehensive method of controlling visibility and opacity at runtime.

Creating a tinted UIImage from given UIImage

I have a image and want to create a black tinted image of same as shown below:
I have a view and a image view as it's subview. The alpha of Image view is 0.5 and its tint color to Black color. Also the background color of view was set to black color. Using this the second screenshot is generated and I want a similar output to a new UIImage.
PS: I need a new image which can stored or reused independent of background views etc.
Also I have tried following so check before reporting duplicate:
How would I tint an image programatically on the iPhone?
Overlaying a UIImage with a color?
Making a UIImageView grey
iPhone: How to Dynamically Color a UIImage
I've also tried getting image from a view but that does not help as I've more components in view not shows here.
iPhone - flattening a UIImageView and subviews to image = blank image might help you with your problem. The idea is to "render in context" a UIView object with 2 subviews (the image, and the black overlay view) to get an image. If you have more subviews which you do not want in the image, simple hide them when rendering.

mysterious white antialiasing behind UIImageView

I'm using a PageViewController to swipe through a series of daily ViewControllers for a week.
The UIViewController that contains the pageViewController contains a few navigation items that do not scroll with the pageViewController. These stay stationary as you swipe. One of these items is a UIImageView, more specifically a UIButton with an UIImageView image representation.
The trouble I'm having is that this stationary UIImageView has a thin white border to it when it should not. I'm giving it a rounded appearance by using rounded corners that are the size of the image. It is easiest seen in this photo. Note, the white "halo" is not part of the image, it appears for any image. The borderColor, imageBackground, view background, and parent view backgrounds are all clearColor. The red background below is part of the swipeable viewController. Interestingly, the white border only appears when it is stationary. If the image/button is placed in the swipeable View it looks great.
Any thoughts how I can get rid of this white antialiasing?
I changed the button's image from using the backgroundImage to just the image property and the white went away entirely. Glad for an easy fix, hope this helps someone else.

UIView background color and transparent png on top

I actually have something simple but I just can't work it out as I'm fairly new to the iOS SDK. So I have a backgroundcolor on an UIView. On top of that I would like to place an image covering the whole UIView as a kind of backgroundimage. The image I'm using is a png which contains transparent areas. I'd like to see the background color through this transparent areas. I do not want to set the transparency of the image itself.
I believe you can set the background color of your view to an image, but this solution should help you learn more about views:
From code (assuming you've added your image to your project):
UIImage *image = [UIImage imageNamed:#"imageFileName"];
UIImageView *imageView = [[UIImageView alloc] initWIthImage:image];
[backgroundView addSubview:imageView];
On storyboard, drag an image view onto your background view. You can configure the image view's frame and image in storyboard. Once you drag the image view into your scene pay attention to where it lands in the view hierarchy. You can choose how exactly you want to set this up, for example, do you want the image view to be a sibling of the background view and lay on top of it? or do you want the image view to be a child of the background view and take up the whole background view's bounds? Same thing as far as the user is concerned, just different organization under the hood.
If you create a transparent area in an image in ex Photoshop, and saving as PNG it will be transparent in Xcode. That's why I always use PNG images.

IOS - How to draw a border and a shadow that rotates with view but doesn't scale with it

I am developing an ios app.
In my app I have got a view, the view is has got a border and a shadow.
The view can be scaled and rotated.
When a user scaled my view it causes my border and shadow to scale as well.
I don't want my shadow or border to scale at all.
On the other hand I do want my shadow and border to rotate when I rotate the view.
Is there any built in mechanism to prevent border \ shadow scale?
Thank you
As far as I know there isn't such a built in mechanism.
The only way I see for you to solve your problem is to simply use two different views, with different management in case of rotation.
Have one view as a sort of background and add your border and shadow to it, and then place the content on top of it (or in it, depends on your case).

Resources