Background view on UITableViewCell hugs content when using slicing xcassets - ios

I have some very simple UITableViewCells, there is just one one-line UILabel and UIImageView (white arrow). UILabel is anchored to it's parent (content view) top/bottom, the arrow is irrelevant now. When I try to set background view to UIImageView that is loading stretchable image from xcassets, this image view hugs the label which is sizeToFit'ed automatically for some reason.
I have set constraints on both label and background view to anchor them to top/bottom of content view, but they still get small.
The cell's height is 50pt, the label is about 20pt so the difference is quite visible.
Any idea what should I do to have background view fill entire content view?
EDIT:
In following image, you can see 2 cells, one of them in selected state. The bottom cell has both background view and selected background view set. Background view (black one) has no vertical slicing, it's simply image with 50pt height, the Selected background view (the red one) has slicing enabled and it hugs the label vertically.
What I want to achieve is to have slicing enabled for both background and selected background view and having it behave like the non-sliced background view on the image, that is filling entire content view of the cell
EDIT 2:
screenshot of cell layout and constraints set on the imageview that is set as background view on cell

I found related question with answer that helped, so this might be a duplicate.
UITableView - SelectedBackgroundView not working in iOS7 with Auto-Layout
Solution is to create those background view programatically as there is probably yet another bug in interface builder that is screwing this up.

Related

How to place any view below any other view which is getting it's position from code

I've created 4 subviews of white color & a yellow one as you can see in reference image I've shared below.
And I've programmatically changed the position of Tabbar from bottom to top just below to navigation bar as you can see in below image (When it is running in the simulator).
Now since I've constraints for that yellow view in image as follow
It is appearing just below to navigation bar but I want it to be displayed just below the Tabbar.
Since Tabbar is getting its position programmatically & other views (including yellow view) are getting their positions from the storyboard.
And since storyboard UIelements are get settled before any other UIelement which are coming from the program or at least get their position from programmatically.
What could be the best way to achieve what I want.
Please refer my storyboard as well to get more understanding. (Refer Below image)
I also want to fit all 5 subviews in the space between tabbar & bottom of the screen. I want to calculate 1/5th of that space & assign this height to each subview. I'd later reduce few pixels to separate them.
Why not add the height of the tab bar to the yellow view's top position? That way, you'd set the constraint something like:
Fajar.top = top + 44
If the tab bar is always visible, then that should work. But of course, if the tab bar only appears at times, you'd probably have to change that constraint programmatically depending on the change ...

In Swift, how to customize the more menu on a tab bar?

I'm trying to change the back ground and size of the cells but on the more menu but am not sure how to do so. Here is what it looks like now:
I want to add a ui image as a backgrounds as well as add a ui image as a background to each cell so it will look like this:
I saw an old post about this on Stack Overflow but it was 7 years old. Does anyone know how to change the more menu in Swift?
In storyboard
1) add a uiImageView to the ViewControll or TableViewControll that you are using. set Constraint UImageView to SuperView as equal width,equal length,central horizontally and central vertically.
set outlet to access.
2) set tableview background to clear colour in attribute property
3)in tableview cell add a UIImageView and set the same equal width, length ,central horizontal and central vertical to contentView.
cell.background colour should be clear .
based on tab you should change the background image in tableview cell imageView in cellforIndexMethod.
you can change the background image of mainBackground in viewDidLoad or viewDidAppear based on the tab

iOS re-order control overlay cell

When having a black background ListView in iOS and setting the edit property to true, shows the re-order control (white horizontal lines icon) in the right hand side as it should. It also shows the delete icon on the left side of the cell and then shifts the contents to the right.
The problem is this; the re-order icon overlays the white text of the cell and you can not see the icon. I know we can't change the background of the re-order control. What am I missing that the content view is not resized but shifted during the re-order?
So as it turns out, the content view label was auto sizing to the entire width of the row. After removing this, the label resizes appropriately.

Image Positioning when resizing

I have an image that is 1000x134 referred to as logo
I have an UIImageView that contains that logo as AspectFit
I have another view in the back
The user is allowed to pan, pinch, and rotate the logo to position it where ever they want on top of the background view
After they have positioned the logo, I then increase the size of the background view
Problem: After the background view's size gets increased, the position of the logo gets messed up.
Question: How do I scale the logo with the background view in order for it to appear in the same position?
You should make the UIImageView a subview of your background view. That would make it easy to resize the whole view, perhaps using self.view.transform.

Autolayout position reset

I have a View and i have a an image view inside it and a another UiView and one or two more view in side the top level view. The problem is when i run my app in different screens iphone the image view resizes and i want the other view to change the their position to a little bit down. But only image view gets more space, but i don't want the other view to get more space but i want them to change their position.
Here i want the white view the Placeholder text and the the small picture view to change their position and go a bit down when the app runs on big screen iphone. Th rounded image view above the Mybutton gets more space when the screen resizes which is okay but the white view and other view remain at their same place. Just to add more information all these view are siblings of each other and i have fixed the the width and height of the white view, picture view and the placeholder text label
Any guidance please?
I think you have to start with the "movable" element and then add every "fixed" element.
I think you have to work with Center Y Alignment Contraint even if you have to create new view for it. The beginning could be :

Resources