Removing Text Shadow - text

I'm not sure if this is changeable, but I'm noticing a slight shadow on the title of my custom navigation controller.
Picture: http://imgur.com/60XjLWE
It's making the text look blurry, which is kind of annoying.
This is the code I'm using: [[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:52.0/255.0 green:54.0/255.0 blue:61.0/255.0 alpha:1.0],UITextAttributeTextColor,
[UIFont fontWithName:#"Helvetica Neue-Bold" size:0.0],UITextAttributeFont,
nil]];
Any idea how to remove the shadow on the title?

You can make it transparent:
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:52.0/255.0 green:54.0/255.0 blue:61.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor,
[UIFont fontWithName:#"Helvetica Neue-Bold" size:0.0], UITextAttributeFont, nil]];

Place this in your AppDelegate
[[UINavigationBar appearance]setShadowImage:[[UIImage alloc] init]];

Related

Converting xcode objective c themes and template to mono/xamarin

I have bought some templates from App Design Vault and they are in XCode/Objective C. I would like to use them in Xamarin Studio/MonoTouch projects, how do I convert them so that they can be used similar to how some themes has been converted in Xamarin's Components Store?
Example of how the App Design Vault template is structured/layout can be downloaded from their website, they have a free template called Ocean: http://emitymeapps.us1.list-manage.com/subscribe/post?u=088ecce4e59f7a30e9aa859af&id=e59abf1e54
Thanks.
Ok, if you look in the AppDelegate.m file of their sample project, there are functions like this:
-(void)customizeiPhoneTheme
{
[[UIApplication sharedApplication]
setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];
UIImage *navBarImage = [[UIImage tallImageNamed:#"menubar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 15, 5, 15)];
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
UIImage *barButton = [[UIImage tallImageNamed:#"menubar-button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
[[UIBarButtonItem appearance] setBackgroundImage:barButton forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
UIImage *backButton = [[UIImage tallImageNamed:#"back.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 14, 0, 4)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
UIImage *minImage = [UIImage tallImageNamed:#"ipad-slider-fill"];
UIImage *maxImage = [UIImage tallImageNamed:#"ipad-slider-track.png"];
UIImage *thumbImage = [UIImage tallImageNamed:#"ipad-slider-handle.png"];
[[UISlider appearance] setMaximumTrackImage:maxImage forState:UIControlStateNormal];
[[UISlider appearance] setMinimumTrackImage:minImage forState:UIControlStateNormal];
[[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateNormal];
[[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateHighlighted];
UIImage* tabBarBackground = [UIImage tallImageNamed:#"tabbar.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage tallImageNamed:#"tabbar-active.png"]];
}
You are basically going to have to port this code to MonoTouch and add their images to your project. But it should be pretty easy, here is a couple lines of code translated to C#:
UIImage navBarImage = UIImage.FromFile("menubar.png").CreateResiableImage(new UIEdgeInsets(5, 15, 5, 15));
UINavigationBar.Appearance.SetBackgroundImage(navBarImage, UIBarMetrics.Default);
Check for mistakes, I did that off the top of my head. I'm also not sure what [UIImage tallImageNamed] is, it must be their own extension. I think you should just use UIImage.FromFile.

customized alert color and increase its frame depending on text input

I am adding a customized alert view and want to change its color to yellow with a textview in it.For this there is a property where we pass the name of a transparent image of that color and alert picks up that color.Also i want to increase the size of alert dynamically depending on the text in textview
Any help would be appreciated
Thanks
Vikas
changed the color with below code .But how to dismiss alert
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"UIAlert View" message:#"hello" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:#"Close",nil];
UIImage *alertImage = [UIImage imageNamed:#"plus.png"];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:alertImage];
backgroundImageView.frame = CGRectMake(0, 0, 282, 130);
backgroundImageView.contentMode = UIViewContentModeScaleToFill;
[alert addSubview:backgroundImageView];
[alert sendSubviewToBack:backgroundImageView];
[alert show];
[alert release];
you can use this code to customize your uialertview..
You can take out the subviews of uialertview and can customize it any way you want.
Here is the code I used to customize the uialertivew
==========
-(void)willPresentAlertView:(UIAlertView *)alertView{
for(UIView *view in alertView.subviews){
view.backgroundColor= [UIColor clearColor];
}
UILabel *title = [alertView valueForKey:#"_titleLabel"];
title.font = [UIFont fontWithName:#"Gibson-Regular" size:15.0];
[title setTextColor:[UIColor whiteColor]];// set title color and font
UILabel *body = [alertView valueForKey:#"_bodyTextLabel"];
body.font = [UIFont fontWithName:#"Gibson-Regular" size:15.0];
[body setTextColor:[UIColor whiteColor]];//set body color and font
//after giving 12345 tag to your alert
UITextView *txtBody=(UITextView*)[alertView viewWithTag:12345];
if(txtBody){//scrollable
txtBody.scrollEnabled = NO;
CGRect frame = txtBody.frame;
frame.origin = CGPointMake(0, 0);
UITextView *txtView = [[UITextView alloc]initWithFrame:frame];
txtView.editable = NO;
txtView.text = txtBody.text;
txtView.font = [UIFont fontWithName:#"Gibson-Regular" size:15.0];
[txtView setTextColor:[UIColor whiteColor]];
[txtBody addSubview:txtView];
txtBody.text=#"";
}
NSLog(#"%#",txtBody.subviews);
for(UIView *view in txtBody.subviews){
view.backgroundColor= [UIColor clearColor];
}
// alertView.backgroundColor=[UIColor redColor];
}

UINavigationItem BackButtonItem not displaying

Using the below code I am implementing my own Navigation Bar. For some reason when I run my app nothing is showing up for a back (left-arrow) button on the navigation bar. However if I change the code to leftBarButtonItem, the button does appear.
// Draw Navigation Bar
UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[navigationBar setDelegate:self];
UINavigationItem *navigationItem = [[UINavigationItem alloc] init];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:#"Back"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
navigationItem.backBarButtonItem = backButton;
[navigationBar pushNavigationItem:navigationItem animated:NO];
[self.view addSubview:navigationBar];
[navigationBar release];
[backButton release];
The backBarButtonItem is set by the parent ViewController.
In other words, it's not set by the ViewController on which you see it but by the ViewController to which it points. So if your ViewController is the first in line, it just won't have a back button.
Also, you are creating a NavigtionBar by yourself. This is usually not the way to go, a UINavigationBar isn't a UI-Element like a Button or a Label. You should rather use a UINavigationController to handle all the pushing and popping of your ViewControllers.
Figured it out:
// Draw Navigation Bar
UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[navigationBar setDelegate:self];
UINavigationItem *navigationItem = [[UINavigationItem alloc] init];
UIButton *button = [UIButton buttonWithType:101];
// add selector
[button setTitle:#"Back" forState:UIControlStateNormal];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:button];
navigationItem.leftBarButtonItem = backButton;
[navigationBar pushNavigationItem:navigationItem animated:NO];
[self.view addSubview:navigationBar];
[navigationBar release];
[backButton release];

How to add a textField to a toolbar

I have a toolbar where I want to post a textField. I'm trying with the following code but it doesn't work:
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:#"Item" style:UIBarButtonItemStyleBordered target:self action:#selector(action:)];
UITextField *customItem1 = [[UITextField alloc] init];
NSArray *items = [NSArray arrayWithObjects: customItem, customItem1, nil];
[self setToolbarItems:items animated:YES];
The toolbar items must all be UIBarButtonItems. In order to display something else, you embed a view into the item:
UIBarButtonItem *customItem1 = [[UIBarButtonItem alloc] initWithCustomView:view];
//view is the embedded view, in your case a UITextField

why I have got such kind of BarButton one upon other?

Hi!I have used UIBarButton Image but i have got such kind of issue.i mean Image+button on backside.for that i have written code below.
UIBarButtonItem *btnMap = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"mapbutton.png"] style:UIBarButtonItemStylePlain target:self action:#selector(btnMapClicked:)];
self.navigationItem.rightBarButtonItem = btnMap;
[btnMap release];
Use initWithCustomView and set a UIButton as the customView instead:
UIButton *subBtn = [UIButton buttonWithType:UIButtonTypeCustom];
subBtn.frame = CGRectMake(0, 0, 50, 40); //adjust as needed
[subBtn setImage:[UIImage imageNamed:#"mapbutton.png"] forState:UIControlStateNormal];
[subBtn addTarget:self action:#selector(btnMapClicked:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btnMap = [[UIBarButtonItem alloc] initWithCustomView:subBtn];
self.navigationItem.rightBarButtonItem = btnMap;
[btnMap release];
Note that the sender in btnMapClicked: will now be a UIButton instead of a UIBarButtonItem.

Resources