-2

I want to put an icon in the header of the view controller like bbc news application, to maximize and minimize the font.

enter image description here

I have to know, is there any library to do that?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
CarinaM
  • 527
  • 4
  • 12
  • 27
  • 1
    what is the need of library for that you can set the background of the button as UIImage – Gyanendra Jun 27 '13 at 10:42
  • no I need the implementation of it, not the view, I know i can put a background of the uiimage, but the action of this button is what? – CarinaM Jun 27 '13 at 10:46
  • I don't know what this BBC button is doing but i guess they are increasing the font of the text for that what you can do is load the content in UIWebView as a html content in some paragraph tag then on successive click on the button you can increase the font size of the of the paragraph or decrease the font size of paragraph that way you can do it. – Gyanendra Jun 27 '13 at 10:52
  • 2
    I Think, the action is execute some Java Script code, because this is a web application... E.g: jsCommand = [NSString stringWithFormat: @"document.body.style.fontSize = 24;",size]; [webView stringByEvaluatingJavaScriptFromString:@"getSelectedNode().style.fontSize"]; – Balazs Nemeth Jun 27 '13 at 10:56
  • http://stackoverflow.com/questions/13877470/change-font-size-for-web-view-in-iphone-sdk – adali Jun 27 '13 at 11:01

3 Answers3

1

Hope this would help you..

UIView *customView=[[UIView alloc]initWithFrame:CGRectMake(10, 0, 40, 40)];

 UIButton *btnAction =[UIButton buttonWithType:UIButtonTypeCustom];
 [btnAction addTarget:self action:@selector(btnActionClick) forControlEvents:UIControlEventTouchDragInside];
 [btnAction setFrame:CGRectMake(0, 0, 40, 58)];
[customView addSubview:btnAction];

 UIButton *btnFont =[UIButton buttonWithType:UIButtonTypeCustom];
 [btnFont addTarget:self action:@selector(btnFontClick) forControlEvents:UIControlEventTouchDragInside];
 [btnAction setFrame:CGRectMake(30, 0, 40, 58)];
 [customView addSubview:btnAction]

 UIBarButtonItem *MessageBtn=[[UIBarButtonItem alloc]initWithCustomView:customView];
Sunny Shah
  • 12,990
  • 9
  • 50
  • 86
0

You can use

[self.navigationItem setRightBarButtonItem:"your button"animated:YES];
Undo
  • 25,519
  • 37
  • 106
  • 129
ldindu
  • 4,270
  • 2
  • 20
  • 24
0

By using following code , you can put the button as you want in the header of viewcontroller.

But to set the font (minimize or maximize), you have to write other code.

You can do google for it.

[self.navigationItem setRightBarButtonItem:"BUTTON"animated:YES];
Rohan
  • 2,939
  • 5
  • 36
  • 65