Rectangle 27 69

I have been using the latter for a lot of nice lightweight animations. You can use it crossfade two views, or fade one in in front of another, or fade it out. You can shoot a view over another like a banner, you can make a view stretch or shrink... I'm getting a lot of mileage out of beginAnimation/commitAnimations.

Don't think that all you can do is:

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:myview cache:YES];
[UIView beginAnimations:nil context:NULL]; {
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationDelegate:self];
    if (movingViewIn) {
// after the animation is over, call afterAnimationProceedWithGame
//  to start the game
        [UIView setAnimationDidStopSelector:@selector(afterAnimationProceedWithGame)];

//      [UIView setAnimationRepeatCount:5.0]; // don't forget you can repeat an animation
//      [UIView setAnimationDelay:0.50];
//      [UIView setAnimationRepeatAutoreverses:YES];

        gameView.alpha = 1.0;
        topGameView.alpha = 1.0;
        viewrect1.origin.y = selfrect.size.height - (viewrect1.size.height);
        viewrect2.origin.y = -20;

        topGameView.alpha = 1.0;
    }
    else {
    // call putBackStatusBar after animation to restore the state after this animation
        [UIView setAnimationDidStopSelector:@selector(putBackStatusBar)];
        gameView.alpha = 0.0;
        topGameView.alpha = 0.0;
    }
    [gameView setFrame:viewrect1];
    [topGameView setFrame:viewrect2];

} [UIView commitAnimations];

As you can see, you can play with alpha, frames, and even sizes of a view. Play around. You may be surprised with its capabilities.

ios - iPhone UIView Animation Best Practice - Stack Overflow

iphone ios cocoa-touch uiview core-animation
Rectangle 27 1

One of my apps does exactly this successfully. The UIView needs to be a peer of the UITableView (i.e. inside the same parent view) and in front of it (after it in the list of the parent's subviews).

Scene
  ViewController
    Top Layout Guide
    Bottom Layout Guide
    View
      Table View
      View  // the view which covers the table view.

Use constraints to make the table a fixed size relative to its superview, and to make the cover view the same size as the table and aligned with it, so it always covers it when visible.

It sounds like you've accidentally put the cover view inside the table or behind it or something.

Amazing. I was working under the impression that the first view in the list was in the front. It is the other way around. Thanks!

ios - Putting a UIView in front of UITableView in a UITableVewControll...

ios uitableview uiview
Rectangle 27 2

From my understanding of your Views stack in your viewController, you simply need to move the transparent view to the front of the stack (it is currently at the back of your superView).

You can do this by calling.

And in the storyboard just set the view to the correct values

If you want to hide the view just call

[self.view bringSubViewToFront:<your tableView>];

To create a transparent view on top of you UITableView, you need to add a UIView in the storyBoard that is a subView of your viewController main view(then set all the attributes you want in the attributes inspector). Your tableView need to be also a subView of your viewController main view.

*make sure that the transparent view is front of the tableView in your storyBoard

In order to handle the gestures (because the transparent view is "blocking" the gestures from the tableView read this post Link)

tried it but not working

if I add [self.view bringSubViewToFront:<your transparent view>];then cellForRowAtIndexPath not getting called

can you add your code? from what you described it's not logical to happen

when do you want your transparent view to be on top? from the beginning?

ios - display list of images in UITableview with trasparent view - Sta...

ios objective-c iphone uitableview uiview
Rectangle 27 13

The custom background image not appearing initially was not fixed in iOS7 GM or final, as far as I can tell. I see the same problem. It does seem to be an Apple bug; the private view Apple uses simply does not get a setNeedsDisplay call when it needs it on initial display. Doing anything to it which causes that call should fix it -- like pressing on it (which likely changes internal state so it calls setNeedsDisplay on itself), or bringing a modal up (which probably forces a redisplay of the entire view hierarchy on the next viewWillAppear: call).

Using leftBarItems instead also can work, but that may cause a lot of maintenance issues with existing code (some screens may have their own left items, expecting that when set back to nil they restore the original back item, for example).

As mentioned, ideally you would be able to change to a borderless look on iOS7, which means that the bug isn't really apparent (since there is no background image). For some iOS6/iOS7 transition situations though, that may be difficult (lots of screens, and/or the need to support older iOS versions for a while and too hard to have two looks implemented, and it doesn't look good borderless without other changes). If that's the case, the following patch should work:

#import <objc/runtime.h>

@implementation UINavigationBar (BackButtonDisplayFix)

+ (void)load
{
    if ([UIDevice currentDevice].systemVersion.intValue >= 7)
    {
        /*
         * We first try to simply add an override version of didAddSubview: to the class.  If it
         * fails, that means that the class already has its own override implementation of the method
         * (which we are expecting in this case), so use a method-swap version instead.
         */
        Method didAddMethod = class_getInstanceMethod(self, @selector(_displaybugfixsuper_didAddSubview:));
        if (!class_addMethod(self, @selector(didAddSubview:),
                             method_getImplementation(didAddMethod),
                             method_getTypeEncoding(didAddMethod)))
        {
            Method existMethod = class_getInstanceMethod(self, @selector(didAddSubview:));
            Method replacement = class_getInstanceMethod(self, @selector(_displaybugfix_didAddSubview:));
            method_exchangeImplementations(existMethod, replacement);
        }
    }
}

- (void)_displaybugfixsuper_didAddSubview:(UIView *)subview
{
    [super didAddSubview:subview];
    [subview setNeedsDisplay];
}

- (void)_displaybugfix_didAddSubview:(UIView *)subview
{
    [self _displaybugfix_didAddSubview:subview]; // calls the existing method
    [subview setNeedsDisplay];
}

@end

Note: UINavigationBar does currently have an override of the method in question, so I'd expect the method_exchangeImplementations style to be used. I just added the other stuff for safety in case Apple changes their code. We may go borderless ourselves, but I did find this approach worked as an option (until a more thorough UI uplift), at least.

Additional note: This bug appears to be fixed in iOS 7.1. So, the patch could be conditionalized to only install the methods if running >= 7.0 and < 7.1.

Thanks! I use this by subclassing the UINavigationBar and overriding the didAddSubview.

cocoa touch - iOS 7 custom back button - Stack Overflow

ios cocoa-touch ios7 xcode5
Rectangle 27 2

The main problem I had was my understanding. Instead of taking a colored view and trying to make a transparent hole in it, we can just layer it the other way around. So we have the colored background in the back, followed by the image in front that has the mask on it to only show the text part. And actually, that's pretty simple if you're using iOS 8+ by using the maskView property of UIView.

let coloredBackground = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
    coloredBackground.backgroundColor = UIColor.greenColor()

    let imageView = UIImageView(frame: coloredBackground.bounds)
    imageView.image = UIImage(named: "myImage")
    coloredBackground.addSubview(imageView)

    let label = UILabel(frame: coloredBackground.bounds)
    label.text = "stackoverflow"
    coloredBackground.addSubview(label)

    imageView.maskView = label

swift - Masking UIView/UIImageView to cutout transparent text - Stack ...

swift uiview uiimageview mask
Rectangle 27 1

  • Use a regular UIViewController with a UITableView added to it. That way, you can add the UIView (or maybe UILabel) to the UIViewController's view. Then, when you have no items to display, you can set the alpha of the UITableView to zero, and the label can be seen.
  • Create a prototype UITableViewCell that displays the "No Items" message you want the user to see.

ios - Putting a UIView in front of UITableView in a UITableVewControll...

ios uitableview uiview
Rectangle 27 0

In IB bring up the Identity Inspector tool (Command-4) then select your custom view and in the Class pop-up choose the name of your custom class instead of generic UIView. You may want to connect it to an ivar as well. In your ViewController declare an instance of your custom class with an IBOutlet in front of it. Then go back and bring up the Connections Inspector and connect your view to the ivar by click-dragging from the custom-view's referencing outlet to the File's Owner (which should be an instance of your ViewController) and choosing the ivar name.

When your NIB is loaded it should be creating an object of that type and connecting it to that variable.

iphone - Custom UIView built with Interface Builder accessible/positio...

iphone uiview interface-builder
Rectangle 27 0

If your view is a static size, then just put a UIView behind it that is 2 pixels wider and 2 pixels shorter than your front view.

If it is non-static sized then you could do the same, resizing the backing view whenever your foreground view is resized, or implement a custom object that implements a UIView, and implement (override) your own drawRect routine.

objective c - UIView set only side borders - Stack Overflow

objective-c ios cocoa-touch uiview
Rectangle 27 0

Yes, sortSubviewsUsingFunction:context: can do what you're looking to do, however it might be overkill if all you'd like is for one particular view to sit on top of the (unordered) others. In that case, you should look into the bringSubviewToFront: method of UIView. That way, you could do something like this in your IBAction for bringing up the handle:

[self.view bringSubviewToFront: handle];

Assuming that handle is an object that is/inherits from UIView. If this isn't what you're looking for, then by all means, go with sortSubviewsUsingFunction:context:, in which case you'll need to alter the individual tag properties for each subview, and sort accordingly.

I'm working on OSX non iOS... but +1 because I can search for similar functions.

Ah, in that case, this looks a little hackish, but you could always add a category to do the following: stackoverflow.com/questions/4236304/

Thank you, I need to understand if this solution, in terms of performance, is better then the sortSubviewsUsingFunction

No problem! I can't say authoritatively that it would be faster, but my thought would be a solid yes. This hinges on the internals of sortSubviewUsingFunction:context:, which I can't comment on. I imagine, however, that it works something like this: 1) manipulate the internal array of subview pointers, then 2) repaint the UI. Certainly ours will be faster for step 1, given that it doesn't iterate through all the subviews like the sort would. For step 2, it's probably either faster or equal, in that the implementation will either repaint all (ours is faster) or repaint just the change (equal).

objective c - Change NSView subviews order - Stack Overflow

objective-c cocoa nsview subviews
Rectangle 27 0

The view hierarchy is like a series of sheets of paper - they can be "on top" of each other, but there is no real depth. As soon as you put a 3D transform on a layer, this will have some depth and, if you've rotated it around the x axis, this will be sticking out in front of the other views.

You could try adjusting the z position of the layer to move it behind other views.

ios - Why does a transformed UIView overlap other views that are highe...

ios objective-c cocoa-touch uiview catransform3d
Rectangle 27 0

If you want the images to stay on top of the table

If you want the images onto of the UItableView consistently then place the UITableView and the two header/footer views as subviews of the same UIView and bring the header/footer views to the front. The trick would be to turn off their userInteraction to touches go through them to the UITableView below.

UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,460)];
[container addSubview:tableView];
[container addSubview:headerView];
[container addSubview:footerView];

headerView.userInteractionEnabled = NO;
footerView.userInteractionEnabled = NO;

You should use tableHeaderView and tableFooterView to set UIViews at the top and bottom of your UITableView instances.

iphone - UITableView covers/hides image? - Stack Overflow

iphone objective-c ios xcode uitableview
Rectangle 27 0

Well, I was build the app tested yesterday to play different music instrument. I use UIView to handle view for 3 of my instrument. The logic is simple. I put the navigation on UIButton and add a subview for each instrument. When the user touch the button, the selected view will be add to the front, and the last view will be release or temporary on the background.

iphone - Best practice for displaying multiple views in iOS - Stack Ov...

iphone objective-c ios ipad ios5
Rectangle 27 0

Not exactly a lot of information to go on here. The simplest solution would be to just bring View2 to the front. theSuperView here is the view that holds both View1 andView2`

theSuperView.bringSubviewToFront(View2)

Another simple solution would be to just hide View1

View1.hidden = true

There are better experiences for a user though. Transitioning to the view with an animation would be much better for this type of instance.

UIView.transitionFromView(View1, toView: View2, duration: .3, options: UIViewAnimationOptions.TransitionFlipFromLeft, completion: nil)

There is a large amount of things you can put into the options parameter here, including:

TransitionNone
TransitionFlipFromLeft
TransitionFlipFromRight
TransitionCurlUp
TransitionCurlDown
TransitionCrossDissolve
TransitionFlipFromTop
TransitionFlipFromBottom

ios - Hide a UIView behind/below other UIView and show from that view ...

ios objective-c uiview
Rectangle 27 0

You can use this code get the index of the view and decide that it is in front or not

UIView* view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
NSLog(@"%d", [[self.view subviews] indexOfObject:view1]); // Is 1

ios - How to check if view, not viewController, is visible or not? - S...

ios objective-c uiview uiviewcontroller
Rectangle 27 0

The effect I am wanting is for the custom UIViews to make it look like the large centered UIView middleView has holes in it

It would be a lot simpler, surely, if the UIView middleView really did have holes in it. This is easily achieved with a layer mask.

For example, this image of Venus has two square holes in it, revealing an angry-looking dude from a Stack Overflow ad behind it:

As I demonstrate, for example, here: stackoverflow.com/a/23452614/341994 The hole I made is a square, but in fact it can be any shape you like. And of course you can have more than one hole.

How would I add multiple masks. I need to have around 20 of these holes and when I use this method, only the last hole is punched in middleView.

Right - you only get one mask on a layer, but that mask can describe multiple holes.

So how do I do this? When I try and add holes the inverse happens and instead of cutting out holes it determines what isn't cut out.

ios - How to display part of a UIView at the back of a view hierarchy ...

ios objective-c xcode uiview
Rectangle 27 0

If your view is a static size, then just put a UIView behind it that is 2 pixels wider and 2 pixels shorter than your front view.

If it is non-static sized then you could do the same, resizing the backing view whenever your foreground view is resized, or implement a custom object that implements a UIView, and implement (override) your own drawRect routine.

objective c - UIView set only side borders - Stack Overflow

objective-c ios cocoa-touch uiview
Rectangle 27 0

Combining UIKit and Cocos2D in such a way that you have the interleaving you have mentioned is likely to be very difficult, because everything done in Cocos2D is drawn in one OpenGL view. When you add a UIView, you can only add it in front of or behind Cocos2D's view.

ios - How to add UITextView in CCLayer or CCScene in cocos2d-iphone - ...

iphone ios cocos2d-iphone
Rectangle 27 0

Make your special view its own UIWindow. Set the UIWindow's windowLevel to UIWindowLevelStatusBar. If it still isn't on top, you can use bringSubviewToFront: on the UIWindow (remember, a UIWindow is a UIView) to bring it to the top of that level.

uiviewcontroller - Hiding iPhone Status Bar pulls my tableViews up by ...

iphone uiviewcontroller uiapplicationdelegate
Rectangle 27 0

The effect I am wanting is for the custom UIViews to make it look like the large centered UIView middleView has holes in it

It would be a lot simpler, surely, if the UIView middleView really did have holes in it. This is easily achieved with a layer mask.

For example, this image of Venus has two square holes in it, revealing an angry-looking dude from a Stack Overflow ad behind it:

As I demonstrate, for example, here: stackoverflow.com/a/23452614/341994 The hole I made is a square, but in fact it can be any shape you like. And of course you can have more than one hole.

How would I add multiple masks. I need to have around 20 of these holes and when I use this method, only the last hole is punched in middleView.

Right - you only get one mask on a layer, but that mask can describe multiple holes.

So how do I do this? When I try and add holes the inverse happens and instead of cutting out holes it determines what isn't cut out.

ios - How to display part of a UIView at the back of a view hierarchy ...

ios objective-c xcode uiview