Hy guys,
I have this view and I wonder how to change its title background color. This code here just change view's body background color:
var invoices = new MainInvoicesView(this);
invoices.Title = "Invoices";
invoices.View.BackgroundColor = UIColor.Gray;
Any ideas?
Regards,
Claudio
What type of view is this? UIViews do not have a Title property, so you're obviously creating a different kind of view.
If you have a UILabel called TitleLabel in your view, and it's public, you should be able to just call:
invoices.TitleLabel.BackgroundColor = UIColor.Blue;
Related
Below is my code I used to create a custom UITextField in code behind.
UITextField usernameField;
usernameField = new UITextField
{
Placeholder = "Enter your username",
BorderStyle = UITextBorderStyle.RoundedRect,
Frame = new RectangleF(10, 32, 50, 30)
};
View.AddSubview(usernameField);
But when I run my app, I dont see this anywhere. Not only this control but all the controls that I create in code behind.
If I drag the controls from toolbox onto my View it's working very fine.
What might be the cause?
Make sure that Container View is not transparent so Alpha = 1 and set background colors for appropriate controlls. Because by default its set to ClearYou can use this method to easly set background and rounded corners like in older versions of iOS
public static void MakeViewRounded(UIView view,float cornerRadius, MonoTouch.CoreGraphics.CGColor backgroundColor)
{
view.Layer.CornerRadius = cornerRadius;
view.Layer.BackgroundColor = backgroundColor;
}
Also make sure that you adding your custom controll to ViewController/View
i need to insert a title (not a tooltip, a text on the top) inside the svg rendered by Dojo. How can i do that?
Here my Dgauge:
http://jsfiddle.net/MacroX/pZU93/1/
PD: The line
gauge.title = 'Test Report'
doesnt show the title
EDIT: The question is regarding a label at the top of the gauge, not the title attribute as I originally thought.
You can use a TextIndicator much like you did for the value label below the needle, but you can set a labelFunc property that defines a function called to set a label and displays whatever string is returned from it.
var labelText = new TextIndicator();
labelText.set('x', 73.3);
labelText.set('y', 55);
labelText.set('labelFunc', function() {return 'Test Report';});
gauge.addElement('labelText', labelText);
Here is a modified version of your fiddle with the title text in place.
Original answer remans below in case someone else needs it
Pass the title in when you create the gauge:
var gauge = new CircularLinearGauge({
title: 'Test Report'
}, dojo.byId("gauge"));
You can also use set to set it after the gauge is created:
gauge.set('title', 'Test Report'); //does work :)
The reason for this is that the gauge widget needs to set the text you give as the title on a specific element within the widget's template. gauge.title just sets the title property of the gauge widget, and the widget has no idea when or with what value that property is being set and thus is not able to make it show up as a title attribute on the gauge.
Finally i got a way to resolve this, and this is useful when you need to personalize your dgauge. Here the example:
http://jsfiddle.net/MacroX/THJqV/
What i did is basicly create a gauge, fill it with background white, and then add elements inside
var baseWidth = 400;
gauge.addElement("background", function (g) {
var auxHeight = baseWidth * objGauge.offsetHeight / objGauge.offsetWidth;
g.createRect({
width: 400, height: auxHeight
//width: 400, height: 300
}).setFill("#FFF");
});
I dont know if is the best way, but works and i didnt find something similar in other sites
And what I think is great, this support multiple chart dgauges in only one SVG
I hope this will useful to someone else
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...
I am implementing a user interface using gxt. I have mainForm class with TabPanel.
TabPanel has few TabItems. On orderManagmentTabItem I have a ContentPanel.
TabPanel mainFormTab = new TabPanel ();
mainFormTab.setAutoHeight(true);
mainFormTab.setAutoWidth(true);
TabItem orderManagmentTabItem = new TabItem("TabItem 1");
orderManagmentTabItem.setAutoWidth(true);
orderManagmentTabItem.setAutoHeight(true);
OrderManagmentTabPanel orderManagmentTabPanel = new OrderManagmentTabPanel(); //contentpanel
orderManagmentTabItem.add(orderManagmentTabPanel);
TabItem warehouseManagmentTabItem = new TabItem("TabItem 2");
warehouseManagmentTabItem.setAutoWidth(true);
warehouseManagmentTabItem.setAutoHeight(true);
So I want to set Autozise to orderManagmentTabPanel, but can't do this. I write setAutoHeight(true) and setAutoWidth(true) in orderManagmentTabPanel class, but whet I run my app orderManagmentTabPanel is empty.
Than I tried to set autosize after creating OrderManagmentTabPanel copy
TabItem orderManagmentTabItem = new TabItem("TabItem 1");
orderManagmentTabItem.setAutoWidth(true);
orderManagmentTabItem.setAutoHeight(true);
OrderManagmentTabPanel orderManagmentTabPanel = new OrderManagmentTabPanel(); //contentpanel
orderManagmentTabPanel.setAutoWidth(true);
orderManagmentTabPanel.setAutoHeight(true);
orderManagmentTabItem.add(orderManagmentTabPanel);
But didn't help also
Also tried to implement TabItem class without ContenPanel and add it to mainFormTab, but also didn't work.
How can I make my TabItem to be autosized?
Thx
OK so I believe you mean (correct me if I am are wrong) you have a panel on a tab item and are trying to ensure it takes 100% of the space?
try setting a layout for example
orderManagmentTabItem.setLayout(new FillLayout()); //Sounds like what your after