UIView as subview won't clip to superview - swift

I have a superview with rounded corners.
It has a custom subview (UIView) that will cover the rounded corners of it's superview. (so the superview will look like it doesn't have rounded corners)
I tried on subview :
self.clipsToBounds=true
but it will still cover the corners of its superview.

You want the clips to bounds on your superview.

Related

Why do these autolayout constraints not resize this UILabel?

In my project I have a UIScrollView view pinned to the edges of the screen. Inside that is a UIView pinned to the edges of the UIScrollView. Inside the UIView I have a UILabel constrained to the UIView so that there are 20 pixels to the left, right, and top of the superview. The problem is that the although the left and top constraints work the right one does not as the label is not correctly resized. I fell like there is something I fundamently don't understand about how constraints work.
my xcode console

Centering vertically in the viewcontroller with navigationbar in swift?

I tried to center an UIImageView in my UIViewController which has a navigation bar at the top and what I wanna do is to have my UIImageView centered between the bottom of the navigationbar and the bottom of the view (with constraints of course). But Xcode make it vertically centered in the view from top of the view (centered between top of the navigationbar and bottom of the UIViewcontroller).
Is there a way to do what I wanna do? with constraints.
Add another UIView (empty) with constraints with top and bottom layout guide. Then add your UIImageView as a subview and align vertically and horizontally.
Try calling self.edgesForExtendedLayout = [] inside viewDidLoad()
Assuming your UIViewController in embedded in a UINavigationController then you should be able to make the center of your UIImageView equal to the center of the UIViewController's view. Otherwise if you added the nav bar manually you will need to offset the center Y coordinate of the UIImageView by the height of the nav bar.

ClipsToBounds on a rotated superview

I am adding a subview on a rotated superview and want it to clip to the superviews bounds.
I know that the bounds are the rectangle around the rotated view and by knowing that I DON'T want to clip it to the superviews bounds but I want it to clip at the actual borders of the rotated superview.
How is that done?

iPhone NavigationBar

[self.navigationController.navigationBar setBounds :CGRectMake(0, 0, 320, 70)];
After increasing navigationBar's height, how can I vertically center the left- and rightBarButtonItem?
Just create a UIView and add a UILabel in it, then add that UIView as a subview to the navigationBar.(Add the UIView in the center)
Do you mean the vertical center?
You can't do this in an easy/supported way, since the extra space on top of the UINavigationBar is intended for help text and not to simply be a taller view. Consider redesigning your center view layout to deal with the fact that UINavigationBar is meant to be a fixed size.

Drawing a shadow below a UIScrollView (that scrolls a UIView)

My setup is a UIScrollView in the center of the screen (on the iPhone - like 300x400 positioned in the center) that contains a UIView of the same width, so it scrolls it vertically. In this UIView i draw custom subviews with labels etc (it's a scoreboard with various colors).
What i'd like to have is some shadow below my UIScrollView, so that the whole scrolling scoreboard floats over my background.
I have found this nice post
How do I draw a shadow under a UIView?
I use this code in my ScrollView subclass but it doesn't work for me. Maybe because I don't draw the actual shapes in the ScrollView's drawRect: (since they are drawn on the UIView).
Also I guess that in order to have the View scroll in the ScrollView and the shadow of the ScrollView outside the scrolling area, I guess I should extend the "bounds" of the ScrollView, right?
It's not quite clear to me what you're asking but, if you want the scrollView contents to scroll over a static image you simply need to add a UIView (or more likely a UIImageView) to your superview and then add your UIScrollView to that. If you set he background colour of the UIScrollView to be celarColor, the background image will show through - so you have a view heirarchy like:
UIWindow
UIView <----- your background here
UIScrollView
Scrolling subviews <----- high score table here
If you draw your highscore table in the scrolling subviews using CoreGraphics, the answer in the question you linked to will also work.
How about explicitly filling the entire self.bounds rectangle in your scroll view subclass' drawRect: method before calling super?
Another idea is to put the scroll view inside of another view which does the shadow drawing.