Zooming in and out of iOS fonts

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.