Swift Color picker for user - swift

I need some help on best direction for creating the following:
An Colours picker that shows a number of colours as small circles
Selected colour is a bigger circle
Allow user to click to select their colour
See image for example of what I mean
I am a bit lost in the best way to create this, I am not looking for the code it self just a direction to go by to create this :)

Using UICollectionView is the easiest available option.
1) Option 1
Use a custom UICollectionViewCell.
Add a view in it with constraints with respect to the superview i.e CollectionViewCell.
Give corner radius to the view to make it a circle.
On selection of the particular collectionViewCell, Update the size of the view and the corner radius to make the circle bigger.
Note : Save the indexPath of the previously selected cell if you want to decrease the size of the previously selected colour option.
2) Option2(Not suggested):
If the numbers of colours are limited. Use a stackView with buttons.
Customise the buttons to the required shape.
Updated the size of the button with respect to the superview i.e Stack.
You can have a single outlet for all the buttons. But you will have to save the instance of the selected button so as to update the previously selected button.

Related

How to add two custom rightBarButtonItems without a margin between them?

I create UIToolbar with interface builder and want to add two custom right buttons, but without a space between them. I don't want solution to reset a margin from the right edge, because I found it here but want only reset margin between buttons.
How should I do this?
Thanks.
Instead of a button, use an UISegmentedControl and set its momentary property to yes.
Add one segment for each button you want (in this case two segments)
Then add an IBAction and use a switch to know what index has been selected.
Index 0 first button, index 1 second button.
Create a bar button item with a custom view where that custom view has 2 UIButtons as subviews. In this way you can exactly size and position the buttons as you require.
To adjust space between UIBarButtonItem's you can use a UIBarButtonItem with style UIBarButtonSystemItemFixedSpace and setting its width property.
You can move items closer to eachother than the default spacing by setting the width of the spacer item to be a negative value.
One thing to consider is future-proofing whichever solution you choose. Buttons in iOS6 have nice borders and shading. They may not in the near future...

Display UITableView's section title when index is touched

I'm writing a dictionary app to study iOS and I've implemented a UITableView with the alphabet as section titles and an index of all the letters on the right side. It works perfectly, but is it possible for me to display the selected index in a box at the center of the screen? I'm looking at the UITableViewDelegate reference but can't see any methods I might override. Help?
You'd have to manually create a UIView that you put above the UITableView which then shows the letter or whatever you want to present. Make sure not to add it to the table view itself as it's a UIScrollView subclass and your view would be affected by its contentOffset.
When the user presses one index or moves his finger above it, this callback gets called:
-tableView:sectionForSectionIndexTitle:title atIndex:
Use it to change your view's contents and make it visible and set a timer for it to fade out again.
You have to create custom view that display when you click on the cell and in that view you can add Label to show the alphabet which you have selected.
And yes also if you want to display it on center of your screen than give its X and Y coordinates value according to it.hope it helps...

Can I customize the check mark position in UITableView?

I'm working on a UITable with allowsMultipleSelectionDuringEditing = true, then I get a circle and red checkmark in the table when it is editing:
The problem is, I need to customize the table view cell such that there are some background image for the cell, and I need a larger margin in the left side of the cell. I can customize the cell contentView for the content position, but are there a way I can customize the checkmark and circle position?
I could have implement a customize table view cell with my own multi selection logic and view, but are there a way I can do it with the built-in multi-select implementation? If not, would you recommend a idiomatic way to do it?
it is possible to change the position of the check mark,
Please make a Table View cell XIB and give it a background image and check mark image and a label ..
the hiding and the display of the check mark will be managed by the associated class of XIB.
it will work for you.
** All the best
To answer my own question, you cannot move the red checkmark and circle (editing control) with public API.
You can however, override the UITableViewCell layoutSubviews method. Inside it find the subview which is a "UITableViewCellEditControl", and modify its position as you wish.

Uitable editing mode make my cell button displays outside the cell

i am using UItable view to show data. i have UIbutton in each cell on right side.when i select edit mode in table my UIButton displays outside from table.please tell me what should i do.
krishan
Use either autoresizingMask in code or the Size Inspector in IB to change the behavior to what you want, depending on how you created your button (code or IB). You can tell it to keep the left margin at a constant size, or change the width, or whatever you decide looks best.

Is it possible to expand the table view's cell at run time?

I am developing an iphone application .
In which i want to show some detailing by the means of expansion of that cell (i.e. by the means of touching the cell it should animate and exapnd and show the details) and in that show the details related to selected row.
What you could do is:
cell is tapped, do a transform on the cell's view to expand it. Fade it out while fading in a new fullscreen view that has some similarity but has the extra data you want displayed. When you are done with that view, shrink it while fading out and fade in the cell view again.
have to update the height of the cell.....