Registering button clicks on image bounds only - ios

I am making an iPhone application that uses hexagon images for button shapes. I add UIButtons to the View and then set the buttons images to be the hexagon image.
My buttons will be layed out like a beehive structure - as per the attached image. If all buttons are in a single row there is no issue.
But when you begin to add multiple rows of buttons, there will be an overlap of buttons - as can be seen by the blue highlighted areas on the attached image.
The dashed lines represent the underlying UIButton shape.
My question is how do I handle these overlapping areas?
For instance, if I add button 3 first to the view and then 1, 2, 4 & 5 in that order to the View, button 3 will only have a very small space for the user to click on to select it as the other buttons will overlap it and have "z-index" presedence (to use a CSS term).
Or the user can click on button 3, but they might click on the top left hand corner of it which will trigger button 1 clicked as an Action.
Alternatively, is there a way to create custom button shapes in Xcode? I can create a button in code but its either a square or a rectangle.
EDIT: I have seen HERE and HERE that allows you to only registers button clicks on button images where the Alpha != 0 but the issue is still that the Alpha for button 1 will overlap button 3 and therefore not register button 3 clicks in the overlapping areas?

Try this Link
https://github.com/ole/OBShapedButton
It gives out a Lib for having buttons sense touch as per its assigned Images

Related

Stop UIButton resizing on background image change

I have built a storyboard with a label, 6 UIButtons in a 3 x 2 grid and another single button below the grid. I've put these into stack views and set up constraints which all seems to work.
I've set the background image of each button which is initially just a grey background (will be more of an icon later) and when a user clicks on the button I change the background image to be a green tick.
However, when it renders, the button increases in size so my 3 x 2 grid looks shoddy.
How can I stop the button resizing when I programmatically change the background (using setBackgroundImage function)?
Try giving some fixed width or height, cause in a stack view it always take what it needs. Or you could make sure buttons are equal between them. Click and drag a button to another with alt key and set it to equal width.

How to add tabs in the cell of tableviewController

hello I want to know how can I add tabs in the tableviewcontroller like this
I want to add tabs Contact and About similar to image and also a line between them. These tabs are in the mid of screen not at the bottom.
I have another question is when I press my thumb on this image portion and move my thumb downwards the image size increases. How can I do that. When I do in my controller white background comes up.
You could put buttons at the bottom of the cell and then have the button handlers reload elements in the cell's view.

UIBarButtonItem active mouse area

I have used two uibarbuttonitems and added a flexible style between them to adjust them at left and right. But when I click just near the buttons the respective actions are got called, even I don't click on the button (here fox example I clicked approx 20px before the right bar button). can any one explain why the action is performed when i click outside of the button not inside it. I check it with custom uitoolbar also and it is show the same problem.
Cocoa-Touch controls usually have larger active touch areas than they are visible on screen. Especially with bar buttons, the touch area can be dynamically enlarged if there are no other bar buttons nearby.

ios any UIView property allows me to set buttons underneath the view in-active?

For ratation and iAd and design reason, I don't want to use modal view to present a message (not via alert view either). I plan to bring up a screen-sized label up and show the message there. That can be done. However, there are a bunch of buttons (ABCD etc) underneath the big label and those buttons are logged in different status and they are clickable. Ideally a user would read the label and disable it via a specified button (X). However, users could click anywhere they want and more than often they will hit those buttons underneath the big label and screw up things. When the big label shows up, only X is visible, and ABCD etc are invisible. Now my question is there any UIView property or whatever property that I can set so that buttons that are invisible are not functioning, although they might be enabled.
You can set the alpha property on your buttons to 0. This will have 2 effects:
1) make the buttons invisible
2) make them ignore the user input
When you need to re-enable the buttons, just set their alpha to 1 again.

Making a pull out tray - (iOS)

I'm making an iPad app, and basically, I want to make a tray that pulls out from the bottom of my app, and I'd like to have a little tab at the bottom of the screen that if you pull, it brings up an image, and the image's height would match the height you pulled the button to. It's a bit like how the notification center works, except the tab is always visible.
So my question is how would I have the image follow the tab as it moves vertically across the screen? I would assume using a UIButton for the tab and a UIImage for the tray would make sense, and I have some code for making buttons move, but how can you make one object follow another?
Thanks for your help,
-Karl
I wouldn't use a button for the tab -- just a regular old view.
To make your image follow the tab (however you implement either of them), simply animate them both together. That is, if you create an animation that moves the center of the button to the Y-coordinate of the user's touch, you can at the same time move the image vertically by the same amount. The two objects will then seem glued together because they move together.

Resources