I'm new in xamarin(start using 2 week), now I need do a background Image wtih navigation bar like below picture? how can I do it?
You need to add an UIImage in your UIViewController (filling whole or only top of ViewController) setting your UINavigationBar to a clear color with
YourNavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
YourNavigationBar.ShadowImage = new UIImage();
YourNavigationBar.Translucent = true;
YourNavigationBar.BackgroundColor = UIColor.Clear;
To reset UINavigationBar transparency you have to use:
YourNavigationBar.SetBackgroundImage(null, UIBarMetrics.Default);
Related
As in subject, I am wondering if right now in React Native is an option to change color of inactive TabBar icon from default gray to custom color? With or without using react-native-vector-icons
I found solution, but your icon should be in "inactive" color. To achieve this go to RTCTabBarItem.m and change first line in method setIcon:
- (void)setIcon:(UIImage *)icon
{
_icon = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
if (_icon && _systemIcon != NSNotFound) {
_systemIcon = NSNotFound;
UITabBarItem *oldItem = _barItem;
_barItem = [UITabBarItem new];
_barItem.title = oldItem.title;
_barItem.imageInsets = oldItem.imageInsets;
_barItem.selectedImage = oldItem.selectedImage;
_barItem.badgeValue = oldItem.badgeValue;
}
self.barItem.image = _icon;
}
Then in all TabBarIOS.Item add field selectedIcon with the same url as in icon (that's no matter), set tintColor of TabBarIOS to "active" color and that's all! TabBar will be rendered with default icon color (inactive), and active icon will be in tintColor. I think that TabBar field renderAsOriginal should do this, but it not works. After all I found this solution on github https://github.com/facebook/react-native/issues/3083
Another solution (may not works in some cases):
in xCode find file RCTTabBar.m (cmd + shift + f)
find - (instancetype)initWithFrame:(CGRect)frame
add before return self:
[[UIView appearanceWhenContainedIn: [UITabBar class], nil] setTintColor: [UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor: [UIColor greenColor]];
Restart Simulator/Device
In code redColor is color of inactive buttons, and greenColor is color of active button. For more details checkout this Unselected UITabBar color?
Edit: I found great tool if you want convert RGB to UIColor http://uicolor.xyz/
any hint on achieving this, ie, animating changes in pages background color of a uiscrollview while user is swiping, synchronizing change in background color with offset change, back and forth ?
Regards,
j.
To make changes in real time while scrolling you should use UIScrollView delegate method:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView;
If you create 2 view controller and add their view as subviews of a scroll view, set the delegate property of your scroll view and add this code inside the delegate:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offset = scrollView.contentOffset.x;
CGFloat factor = offset / scrollView.bounds.size.width;
_leftVC.view.backgroundColor = [UIColor colorWithHue:factor saturation:1.0 brightness:1.0 alpha:1.0];
_rightVC.view.backgroundColor = [UIColor colorWithHue:0.3 saturation:1.0 brightness:factor alpha:1.0];
}
It just change the background color, but you can do everything you need synchronized with the scroll view offset.
I create an image-button using below code:
ImageBrush btnBrush1 = new ImageBrush();
btnBrush1.Stretch = Stretch.Uniform;
btnBrush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Images/icon_LogIn.png"));
btnLogIn.Background = btnBrush1;
The problem:
1) When using a mouse hovering the img-button, it turn grey background and icon disappear ( when not hovering the img-button, this image button is visible.
I want this image-button visible when hovering it or pressing it.
Thanks
You need to set Image as Content rather than setting ImageBrush as Background.
Try this
Image img=new Image();
img.Source=new BitmapImage(new Uri("/Images/icon_LogIn.jpg",UriKind.RelativeOrAbsolute));
btnLogIn.Content = img;
I am attempting to write an application with MonoTouch. I need to set the background color of the navigation bar. I'd like to set it to orange. This seems like an easy task, but I can't seem to get it to work. Currently, I'm doing the following in the AppDelegate.cs file:
this.window = new UIWindow (UIScreen.MainScreen.Bounds);
this.rootNavigationController = new UINavigationController();
UIColor backgroundColor = new UIColor(74, 151, 223, 255);
this.rootNavigationController.NavigationBar.BackgroundColor = UIColor.Orange;
However, the navigation bar color is still the default color. How do I set the background color of the navigation bar?
You can do this on an ad-hoc basis as Rob described using the TintColor property:
this.rootNavigationController.NavigationBar.TintColor = UIColor.Orange;
Alternatively, you can also set the TintColor for all UINavigationBars at once using the UIAppearance proxy in iOS 5. This is usually done somewhere near DidFinishLaunchingWithOptions method in the AppDelegate:
UINavigationBar.Appearance.TintColor = UIColor.Orange;
You can check out the Apple doc for more detailed information and implementation restrictions:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html
Try changing the TintColor and Translucent properties.
From top to bottom I have UIView, UIScrollView, a UIImage, a UILabel, a UITextView and a UIButton.
My reason behind the top-most UIScrollView was so the whole vertical content would scroll.
What I really need a substitute for is the UITextView (5th down) because the UITextView is a subclass of UIScrollView. And this substitute must accomodate the very tall column of formatted text.
What I don't want is a scrollable object in the middle of the page; I want the whole page to be scrollable.
One more thing ... please note there's a button immediately below this tall column of text.
John Love
THANK YOU! Ashack and Pentagp. I guess I finally had to surrender and dump the idea that IB could be used for all GUI ...
The entire UIView contains a UILabel, a UIImage, a UITextView and
a UIButton at the very bottom.
The goal here was to make this entire content scrollable.
Thanks to you guys at stackoverflow.com:
using IB, un-check "Scrolling Enabled" for the UITextView
because it's a concrete type of UIScrollView
using IB, drag a UIScrollView to the UIView and match sizes and
insure that the UIScrollView encloses all sub-views
make the UITextView height = its contentSize.height
move the UIButton to below this UITextView
and then, thanks to iphonedevsdk.com:
adjust the contentSize.height of the top-most UIScrollview to
include the height of the re-positioned UIButton
Problem solved!!!
Your question is not very specific, but I think you're asking how to make a text view that does not scroll, and expands to fit the text. You can do this with UILabel, but it's a multi-step process. The same will work for UITextView if you disable scrolling and set the contentSize to match the frame dimensions.
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100,100,100,100)];
label.font = [UIFont systemFontOfSize:24];
NSString *yourTextString = #"your text";
CGSize maximumLabelSize = CGSizeMake(100, 500);
CGSize expectedLabelSize = [yourTextString sizeWithFont:label.font
constrainedToSize:maximumLabelSize
lineBreakMode:yourLabel.lineBreakMode];
CGRect labelFrame = label.frame;
labelFrame.size.width = expectedLabelSize.width;
labelFrame.size.height = expectedLabelSize.height;
label.frame = labelFrame;
Then from there, use the label's frame to set the position of the button and all elements below it.
If I understand your problem, you don't want nested scroll.
So set yourTextView.scrollEnabled = NO; //Do it programmatically our in the nib
Also in order to display all the text set yourTextView frame height to its content height:
yourTextView.frame = CGRectMake(yourTextView.frame.origin.x,
yourTextView.frame.origin.y,
yourTextView.frame.size.width,
yourTextView.contentSize.height + (yourTextView.contentSize.width > yourTextView.frame.size.width ? (yourTextView.contentSize.width * yourTextView.contentSize.height / (yourTextView.contentSize.width - yourTextView.frame.size.width)) - yourTextView.contentSize.height :0)));
/*
If textView is dynamically filled, you have to check if yourTextView.contentSize.width is bigger than yourTextView.frame.size.width then add proportionally what is remaining to the height.
*/
At the end change your button position if needed:
yourbutton.frame = CGRectMake(yourbutton.frame.origin.x,
yourTextView.frame.origin.y + yourTextView.frame.size.height + 20, //If you want your button to be 20 point after your textView
yourbutton.frame.size.width,
yourbutton.frame.size.height);
Hope that will help you...