1.-(void) Viewdidload first set the global variables of the font
Font=+;
2. Customize 2 buttons and add an event
// zoom in
_zoominbtn = [UIButton buttonwithtype: Uibuttontypecustom];
_zoominbtn. frame = CGRectMake (185, 7, + );
_zoominbtn.backgroundcolor = [Uicolor clearcolor
[_zoominbtn Setimage:[uiimage Imagenamed : @ "Buttonzoomin.png" "forstate :uicontrolstatenormal
_zoominbtn. Tag = 220
[_zoominbtn addTarget:self Action:@selector(fontsizeadjustment:) forcontrolevents : UIControlEventTouchUpInside];
[Englishsetview Addsubview:_zoominbtn];
// zoom out
_zoomoutbtn = [UIButton buttonwithtype: Uibuttontypecustom];
_zoomoutbtn. frame = CGRectMake (265, 7, + );
_zoomoutbtn. BackgroundColor = [Uicolor clearcolor];
_zoomoutbtn. Tag = 221
[_zoomoutbtn Addtarget:self Action: @selector (fontsizeadjustment:) forcontrolevents: Uicontroleventtouchupinside
[_zoomoutbtn setimage: [UIImage imagenamed:@ "Buttonzoomout.png"] forstate: UIControlStateNormal];
[Englishsetview Addsubview:_zoomoutbtn];
3. Implementation methods
#pragma mark- font sizing Events
-(void) Fontsizeadjustment: (ID) sender
{
NSLog (@ "%f",font);
UIButton * btn = (UIButton *) sender;
if (btn = = _zoominbtn) {
if (font<) {
font = font+1;
[_zoomoutbtn setenabled:YES];
[_englishdetailtable reloaddata];
}
Else
{
uialertview * alert = [[uialertview alloc] initwithtitle:nil message:@ " "Delegate:nil cancelbuttontitle:@ " OK "Otherbuttontitles: nil];
[Alert show];
[_zoominbtn setenabled:NO];
}
}
Else
{
if (font>) {
font = font-1;
[_zoominbtn setenabled:YES];
[_englishdetailtable reloaddata];
}
Else
{
uialertview * alert = [[uialertview alloc] initwithtitle:nil message:@ " "Delegate:nil cancelbuttontitle:@ " OK "Otherbuttontitles: nil];
[Alert show];
[_zoomoutbtn setenabled:NO];
}
}
}
Zooming in and out of iOS fonts