gradient background iOS - ios

This rectangular region has a gradient background which is also transparent. Texts can be written on the rectangle. The colour of the rectangle changes when the user touches it. When the user releases it, it takes you to a new screen. How should something like this be implemented in iOS?

Use
UIImageView with gradient backgroundImage
set its alpha to 0.6 -.75 so that background view is visible
Use Tap gesture recognizer on ImageView to change background Image when user tap and navigate to next view

Related

Apply blur effect on tap or selected area if UIImageView

I have a simple setup:
UIViewController->UIView->UIImageView
I want to achieve blur on UIImage which is loaded in UIImageView only on the area that user select or tap or move the finger.
Is it possible using UIVisualEffectView?

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.

Setting Animation behaviour for UIImageView

I have an image view which is a circle with the upper half in black and the lower half as white with another black circle at the center.
If I swipe up then the white color should increase from both the ends simultaneously... I have added a UISwipeGestureRecognizer and gestures are detected
How to increase the color from the lower half using animation?
Is there a way where I can set alpha value while swiping up, using animation?
Several things:
A swipe gesture is a one-shot. It fires once, and doesn't give you a chance to animate as the user drags. You want a pan gesture recognizer for that.
There is no off-the-shelf animation that will animate color changes to different parts of the image as you describe. You'll have to create your own. Your description is kind of vague, so it's a bit hard to give you suggestions. Do you want to replace the previous contents of your image view with pure white, coming from the top and bottom, or do you want to brighten your original image view towards white? You need to describe the effect you're after in a lot more detail. You could probably get the effect you are after using Core Animation and either a CAGradientLayer or a CAShapeLayer. A gradient layer could act as either an overlay that would cover the image view underneath, or as a mask that would reveal a new image on top in the final state you're after.
As to your question #2, animating the alpha is trivial. Again, you need to use a pan gesture recognizer, not a swipe gesture recognizer. Then you could adjust the alpha value of the view as the pan position moves up the view. You could also trigger a crossfade style animation with a swipe gesture, and use UIView animation methods like animateWithDuration:animations:

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.

UIButton custom image alpha

I have some buttons close to each other in a logo shape, they are non rectangular shapes and I was wondering if I can exclude the transparent parts of the button from receiving touches, so that the elements behind it can receive the touches instead?.
Can you make the alpha parts of the button image not part of the button? , or , if the user touches these alpha parts, the button below will be tapped?
You would normally have to subclass UIButton, but luckily someone has taken care of this for you already:
https://github.com/ole/OBShapedButton
This seems to be exactly what you're looking for.

Resources