iOS White to Transparent Gradient Layer is Gray
clearColor has a black color channel with an alpha of 0, so I had to use [UIColor colorWithWhite:1 alpha:0] and it works fine.
clearColor has a black color channel with an alpha of 0, so I had to use [UIColor colorWithWhite:1 alpha:0] and it works fine.
Thanks for help. This is the solution: I created the subview and i add a gesture to remove it @IBAction func infoView(sender: UIButton) { var testView: UIView = UIView(frame: CGRectMake(0, 0, 320, 568)) testView.backgroundColor = UIColor.blueColor() testView.alpha = 0.5 testView.tag = 100 testView.userInteractionEnabled = true self.view.addSubview(testView) let aSelector : Selector = “removeSubview” let tapGesture = … Read more
You can set background color of view to the UIColor with alpha, and not affect view.alpha: view.backgroundColor = UIColor(white: 1, alpha: 0.5) or view.backgroundColor = UIColor.red.withAlphaComponent(0.5)
Whenever I want to display some overlay on top of everything else, I just add it on top of the Application Window directly: [[[UIApplication sharedApplication] keyWindow] addSubview:someView]
You are probably looking for UIView’s -(BOOL)isDescendantOfView:(UIView *)view; taken in UIView class reference. Return Value YES if the receiver is an immediate or distant subview of view or if view is the receiver itself; otherwise NO. You will end up with a code like : Objective-C – (IBAction)showPopup:(id)sender { if(![self.myView isDescendantOfView:self.view]) { [self.view addSubview:self.myView]; } … Read more
A simpler alternative to UIDynamicAnimator in iOS 7 is Spring Animation (a new and powerful UIView block animation), which can give you nice bouncing effect with damping and velocity: Objective C [UIView animateWithDuration:duration delay:delay usingSpringWithDamping:damping initialSpringVelocity:velocity options:options animations:^{ //Animations } completion:^(BOOL finished) { //Completion Block }]; Swift UIView.animateWithDuration(duration, delay: delay, usingSpringWithDamping: damping, initialSpringVelocity: velocity, options: … Read more
Yes. You can override the hitTest:withEvent: method to return a view for a larger set of points than that view contains. See the UIView Class Reference. Edit: Example: – (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { CGFloat radius = 100.0; CGRect frame = CGRectMake(-radius, -radius, self.frame.size.width + radius, self.frame.size.height + radius); if (CGRectContainsPoint(frame, point)) { return self; … Read more
MyViewClass *myViewObject = [[[NSBundle mainBundle] loadNibNamed:@”MyViewClassNib” owner:self options:nil] objectAtIndex:0] I’m using this to initialise the reusable custom views I have. Note that you can use “firstObject” at the end there, it’s a little cleaner. “firstObject” is a handy method for NSArray and NSMutableArray. Here’s a typical example, of loading a xib to use as a … Read more
It’s worth noting that if you’re targeting iOS 7 and above, you can use the new UIView method performWithoutAnimation:. I suspect that under the hood this is doing much the same as the other answers here (temporarily disabling UIView animations / Core Animation actions), but the syntax is nice and clean. So for this question … Read more
I’m still trying to figure this out myself, so take this with some skepticism and forgive me if it contains errors. setNeedsLayout is an easy one: it just sets a flag somewhere in the UIView that marks it as needing layout. That will force layoutSubviews to be called on the view before the next redraw … Read more