View controller with background image and transparency xamarin - ios

I kind of stuck with a design issue in iOS.
I have a controller with a background image, nothing special.
this.View.BackgroundColor = UIColor.FromPatternImage (UIImage.FromFile ("Images/ballons.jpg"));
On top of the controller I have a view with a background color (white) that is semi-transparent.
this.Frame = new System.Drawing.RectangleF (0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);
this.BackgroundColor = UIColor.White;
this.Alpha = 0.5f;
Now the issue is if I add a button or any other controls in my view they also becomes transparent...so am I thinking wrong here...?
I would like the controller to have a background image, the view a white semi-transparent background and all the controls (buttons, images) not to be transparent at all...

Do not change the Alpha of the view, since that will change the transparency of all its elements/subviews. Just set its BackgroundColor to a semi-transparent color using UIColor.FromWhiteAlpha(1, 0.5).

Related

Separate colors for viewcontroller background and statusbar background

I want a blue color for my navigation bar and status bar backgrounds while a white color background for the rest of the view controller. I want this for all my view controllers in the app. Naturally, I have in my BaseViewContrller for statusbar:
self.view.backgroundColor = UIColor.blue
But this causes the whole view controller to go blue. Is adding a white UIView and constraining it to safe areas the only option or there is an easy way to accomplish this?
Yes, because you're setting ViewController's view background color and not navigationBar background color. Instead set background color of navigation bar
navigationController?.navigationBar.backgroundColor = .blue

Working with transparency: View behind transparent view should only shine through and not overlap

I'm currently working with transparency and I'd like to have the following effect:
As you can see the line takes the full width of the view. There are some transparent UIViews also on this screen. The line seems to be below the transparent UIView and if it overlaps it has another color, because of the transparent UIView above. When there is no overlapping the line get its normal color.
How can I get this effect?
I tried to set the background of the UIView to transparent, but it didn't helped. The line has its normal color and doesn't interact with the transparency. Furthermore I tried to change the transparency of the view itself but with the same wrong result.
The rectangle above is done with code
UIView rectangle = new UIView (new CGRect (10, 10, 200, 120));
rectangle.BackgroundColor = UIColor.FromRGBA (204,115,225, 50);
UIView line = new UIView (new CGRect (0, 105, 320, 1));
line.BackgroundColor = UIColor.Red;
View.AddSubview (line);
View.AddSubview (rectangle);
line.SendSubviewToBack (rectangle);
the rectangle below is created in iOS designer.
Am I missing something?
Its all about the z order of the Subviews.
line.SendSubviewToBack (rectangle);
is probably not what you want.
If you add the line with its normal red color and add a UIView that has its alpha dropped to e.g. 0.5, then you should get the effect you want.
The z-order of the subviews was correct in my case. Depending on the color the effect I want is possible or not. So I made the following:
Choose another background color for the lavender color rectangles and adapt the alpha transparency to look similar. So something like this:
rectangle.BackgroundColor = UIColor.FromRGBA (245/255.0f,227/255.0f,249/255.0f,0.7f);

How can I blur the background of table with out blur the row content?

I have a table on the backgroundview like this:
i want to set my tableview with blur animation on the background like this:
I tried to set the background color of table to black and set the alpha of that to 0.1 :
self.lapTable.backgroundColor = UIColor.blackColor()
self.lapTable.alpha = 0.1
but when I do that, all of my row have alpha 0.1 too:
How can I blur the background of table with out blur the row content?
Set tableview background color clear
self.lapTable.backgroundColor = UIColor.clearColor()
and make a UIView in background of UITableView and set transparent background of UIView
It will work same as like you ...
If you just want to set the background color like in your initial attempt, you could create a translucent color:
let translucentBlack = UIColor(white: 0, alpha: 0.6)
You could also set tableView.backgroundView to an instance of UIVisualEffectView with effect set to an instance of UIBlurEffect.
Successfully to make what i want. simple add another view under my table view and view's background color to black with alpha, after that set the background of tableview to clear color.

Hard time setting color on status bar (iOS7) with transparency

I would like my status bar to be black and be 25% transparent. I understand that the status bar is transparent by default, and therefore takes on the color of the background. However when I set the views backgroundColor:
self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.75f];
The status bar is completely black.
I have a toolbar which I set to black with an alpha of .75 and I am just trying to get them to match:
self.toolBar.tintColor = [UIColor whiteColor];
self.toolBar.barTintColor = [UIColor blackColor];
self.toolBar.alpha = .75f;
Any reason why the background color on the UIView is not respecting the alpha component?
EDIT:
Based on comment that view does not underlap the status bar. If I set background to green it shows that it works:
However if I start to add transparency to the green color, it does not get lighter it gets darker. Seems like the default is to be black underneath my only UIView, not white.
self.view.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:.25];
The status bar in iOS 7 is completely transparent. The problem may be that your view and the toolbar are not correctly underlapping the status bar. So you are seeing the black window behind it. (Or, in fact, you may setting the size of the window incorrectly, in which case you are seeing nothing at all behind the status bar.)
If the view does underlap the status bar, then you need to set the bar positioning of the toolbar to Top Attached so that its height increases up underneath the status bar. We should not be seeing a separate color for the status bar; it should appear to overlay your interface, lying in front of the top of the toolbar.

How to remove black background on UITabBar

I want to create the TabBar which align at center no matter what how many tabitem is.
The final result may be look like the image below.
I can set width of TabBar by using
UITabBar *tabBar = self.tabBarController.tabBar;
CGRect rectAdjust = CGRectMake(tabBar.frame.origin.x, tabBar.frame.origin.y, 160.0f, tabBar.frame.size.height);
tabBar.frame = rectAdjust;
But I cannot remove the black background on UITabBar(on the right side in below image) even though I already set the size of TabBar to be half the screen's width.
Is there any way to solve this?
Thanks.
Instead of reinventing the wheel, you could take a look at this control at the CocoaControls website:
ALTabBarController for iOS
It is more customizable than the traditional TabBar
You could set an image for the table bar that has caps on either side and a few pixels in between, then make it a resizeable image like so:
UIImage *background = [[UIImage imageNamed:#"ImageName.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
Then set it as the background image of the tab bar:
tabBar.backgroundImage = background;
And it should resize to the image you need.
Then set the background color of the tab bar to clear:
tabBar.backgroundColor = [UIColor clearColor];

Resources