UIButton with custom shadow image - objective-c

I need to achieve effect of my button like this:
My questions are:
How can I add this custom shadow to button, so only 'BUTTON' surface reacts for touches?
When I have the next button in the bottom, close to previous one, how can I be sure that it will not be covered by upper's button shadow?
I need to have all the buttons in front and all the shadows in the back.

If you want to add the shadow without having it clickable, you need to add an imageView to as a subview to the button. (make sure clip subviews is disabled).
If you want the shadow of one button not appearing on top of the other, then you need to have the shadow(s) added separately to the main parent view. The solution in option 1 will not work. Its not neat, but its the only way i can think off.

Related

disable touches behind a sprite

I have a menu in my app, with clickable buttons using CCMenuItemImage. When you press one of the buttons, for example buy button it spawns anther image on top of everything, a confirmation screen(do you really want to buy this item). This screen is placed on z:100 just to be sure it is on top of everything.
The problem is the buttons on the menu below(buy, back, next(all CCMenuItemImage)) are still clickable. I had the idea to just use [button setIsEnabled:NO]; but this doesn't seem to work unless the CCMenuItemImage has a disabledImage set, but some of my buttons (next, previous) use the disabledImage and it looks silly to make the buttons disabled when this confirmation screens shows up.
Is there a way to just disable all the touches to the buttons below and only allow the confirm screen to take touches?
Set the enabled property of the CCMenu to NO. If that doesn't work without disabled images simply set the CCMenu visible property to NO. This also disables the menu reacting to touches.

Can't seem to achieve the same effect on my slide menu as Any.Do

I am trying to create the same type of slide-up/pull-up menu (from the bottom) as the Any.do iPhone app, but not having any success.
The issue I am running into is the app was built with storyboards so I am thinking I might have to scratch that idea and use just code.
Any ideas?
There is no need to get rid of your storyboard to recreate this, that's what IBOutlets are for. Any way, it looks like this was made by creating a UIScrollView that takes up the entire screen. Then add a UITableView to the upper section of the scroll view. Mind you in order for this to work, you'll need to disable scrolling on the scroll view in the background.
From there you can programmatically add the other elements to the scroll view to be rendered off screen, since there are only three they can probably just be buttons. And finally, since scrolling is disabled on the background scroll view you can add an image with a UISwipeGestureRecognizer at the bottom of the screen to manually change the scroll view's content offset property.

Changing what is loaded by a nib file

in my iPad application I have a panel of buttons, I have used an UIImageView as this panel and put buttons on top of it and created my nib file. in some views some button of this panel should not be displayed. so what i do is removing those buttons and decreasing the height of the panel (a UIImageView) then reposition the button to take up the space of the removed button. I have created outlets to all of these.
Is this the way to do this? My problem is if I want to change the order my buttons are displayed at some point I can't do it by simply changing the nib file. I'll have to do some changes in the code as well.
In this case don't use the nib to position the buttons in the first place. It sounds like this is one of the occasional cases where you would be better off working solely from code.
Instead of having to worry about some sort of abstraction that protects your layout if you decide to reposition the buttons and about removing and repositioning buttons, you can just do the layout at runtime once your particular view knows what buttons it needs. Your code is already doing much of the work of layout already (removing and repositioning).

adding an invisible button to the background in IB

I'm working with Xcode doing a Ipad app.
i simply want user to click anywhere on screen (not counting text fields) to perform some IBAction.I'm using an invisible button that covers my whole view.
Since I have some text fields in my view,i need to add this invisible button to the background of my user interface. I cant seem to find this option in the button attributes? any help?
Just set the button's type to custom.
Did you try setting the opacity of the button to zero?
I guess i got your point. You just want to put the UIButton(invisible) on the back of all the UITextField. The simple solution to this is open the Document Window in the IB. Now expand the view tree in the list view. Just drag your UIButton above the UITextFields and set the alpha value for the button in the property to be zero.
Hope this helps!!
iPad users don't "click". They "tap" or "touch".
In Interface Builder, I believe views are constructed with a z-index from top to bottom as they appear in the document window, so dragging your button so that it appears as the first subview of your main view should be a quick fix for this.
Have you considered other approaches? This doesn't sound like standard behaviour for an app and will probably cause havoc with anybody using Voice Over. What are you trying to accomplish?

How to include other controls in a scrollbar?

I want to create a scrollview with a zooming control and a button next to the scrollbar. Sort of like the "tile window" button in XCode (top right corner of the editor), it should be in the same box that usually is used by the scrollbar only.
Do you have an idea of how to approach this?
I was thinking to use an NSScrollView and set the scrollbars to a custom subclass of NSScroller which includes the other widgets. What kinds of buttons use the same style as the scrollbar?
Subclass NSScrollView and override -tile. You'll add the subviews on -init... or nib awake (or some other convenient time) and lay out the controls manually in your overridden -tile method. If you call [super tile] first, then adjust the bottom or right scroll bar to make room for your custom control(s), your job will be a lot easier.