objective c - How to create UIButton for ios7 & ios6 4-inches and 3.5 screen for iOS -
i working on ios7 & ios6(3.5 inches , 4 inches screen).
- i displaying 6 buttons in uiview.the 6 buttons divided in 3 rows.like each 2 buttons displaying single row.
- total rows displayed 3.
- i have integrated iad in bottom of view.
my problem in ios7 4-inches screen display proper way. in ios 6 4-inch screen not display properly. have issues alignment. ios7 3.5 inches getting alignment issues. ios6 3.5 inches displays fine.
i don't know how fix alignment issues. sample code:
#define system_version_greater_than_or_equal_to(v) ([[[uidevice currentdevice] systemversion] compare:v options:nsnumericsearch] != nsorderedascending) - (void)viewdidload { [super viewdidload]; if (system_version_greater_than_or_equal_to(@"7.0")) { [[uiapplication sharedapplication] setstatusbarstyle: uistatusbarstyledefault]; navibarobj=[[uinavigationbar alloc]initwithframe:cgrectmake(0, 20, 320, 64)]; [self.view addsubview:navibarobj]; [navibarobj setbartintcolor:[uicolor colorwithred:38.0f/255.0f green:45.0f/255.0f blue:51/255.0f alpha:1.0]]; // weekly audio button creation.. weeklyaudio=[uibutton buttonwithtype:uibuttontypecustom]; [weeklyaudio addtarget:self action:@selector(weeklypredictions) forcontrolevents:uicontroleventtouchupinside]; [weeklyaudio settitle:@"weekly" forstate:uicontrolstatenormal]; weeklyaudio.titlelabel.textalignment = nslinebreakbywordwrapping; weeklyaudio.titlelabel.numberoflines = 2; [weeklyaudio.titlelabel settextalignment: nstextalignmentcenter]; [weeklyaudio settitleedgeinsets:uiedgeinsetsmake(60, 10, 10, 10)]; [weeklyaudio.titlelabel setfont:[uifont systemfontofsize:14.0]]; weeklyaudio.frame=cgrectmake(10, 100, 140, 120); weeklyaudio.layer.cornerradius=5; weeklyaudio.backgroundcolor=[uicolor colorwithred:232.0f/255.0f green:52.0f/255.0f blue:27.0f/255.0f alpha:1.0]; [self.view addsubview:weeklyaudio]; weeklyaudioimage=[[uiimageview alloc]initwithframe:cgrectmake(45, 10, 48, 48)]; weeklyaudioimage.image=[uiimage imagenamed:@"48*48.png"]; [weeklyaudio addsubview:weeklyaudioimage]; weeklyaudio.autoresizingmask = uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin |uiviewautoresizingflexiblebottommargin | uiviewautoresizingflexibletopmargin; // create yearly audio button. yearlyaudio=[uibutton buttonwithtype:uibuttontypecustom]; [yearlyaudio addtarget:self action:@selector(yearlypredictions) forcontrolevents:uicontroleventtouchupinside]; [yearlyaudio settitle:@"yearly" forstate:uicontrolstatenormal]; yearlyaudio.titlelabel.textalignment=nslinebreakbywordwrapping; yearlyaudio.titlelabel.numberoflines=2; [yearlyaudio.titlelabel settextalignment:nstextalignmentcenter]; [yearlyaudio settitleedgeinsets:uiedgeinsetsmake(60, 10, 10, 10)]; [yearlyaudio.titlelabel setfont:[uifont systemfontofsize:14.0]]; yearlyaudio.frame=cgrectmake(160, 100, 140, 120); yearlyaudio.layer.cornerradius=5; yearlyaudio.backgroundcolor=[uicolor colorwithred:16.0f/255.0f green:144.0f/255.0f blue:209.0f/255.0f alpha:1.0]; [self.view addsubview:yearlyaudio]; yearlyaudioimage=[[uiimageview alloc]initwithframe:cgrectmake(45, 10, 48, 48)]; yearlyaudioimage.image=[uiimage imagenamed:@"48*48.png"]; [yearlyaudio addsubview:yearlyaudioimage]; yearlyaudio.autoresizingmask = uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin |uiviewautoresizingflexiblebottommargin | uiviewautoresizingflexibletopmargin; // iad integration. adbannerview *adview = [[adbannerview alloc] initwithframe:cgrectzero]; adview.frame=cgrectmake(0, 580, 320, 40); adview.delegate=self; adview.autoresizingmask =uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin |uiviewautoresizingflexiblebottommargin | uiviewautoresizingflexibletopmargin; } else { weeklyaudio=[uibutton buttonwithtype:uibuttontypecustom]; [weeklyaudio addtarget:self action:@selector(weeklypredictions) forcontrolevents:uicontroleventtouchupinside]; [weeklyaudio settitle:@"weekly" forstate:uicontrolstatenormal]; weeklyaudio.titlelabel.textalignment = nslinebreakbywordwrapping; weeklyaudio.titlelabel.numberoflines = 2; [weeklyaudio.titlelabel settextalignment: nstextalignmentcenter]; [weeklyaudio settitleedgeinsets:uiedgeinsetsmake(60, 10, 10, 10)]; [weeklyaudio.titlelabel setfont:[uifont systemfontofsize:14.0]]; weeklyaudio.frame=cgrectmake(10, 50, 140, 110); weeklyaudio.layer.cornerradius=5; weeklyaudio.backgroundcolor=[uicolor colorwithred:232.0f/255.0f green:52.0f/255.0f blue:27.0f/255.0f alpha:1.0]; [self.view addsubview:weeklyaudio]; weeklyaudioimage=[[uiimageview alloc]initwithframe:cgrectmake(45, 10, 48, 48)]; weeklyaudioimage.image=[uiimage imagenamed:@"48*48.png"]; [weeklyaudio addsubview:weeklyaudioimage]; weeklyaudio.autoresizingmask =uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin |uiviewautoresizingflexiblebottommargin | uiviewautoresizingflexibletopmargin; // create yearly button audio yearlyaudio=[uibutton buttonwithtype:uibuttontypecustom]; [yearlyaudio addtarget:self action:@selector(yearlypredictions) forcontrolevents:uicontroleventtouchupinside]; [yearlyaudio settitle:@"yearly" forstate:uicontrolstatenormal]; yearlyaudio.titlelabel.textalignment = nslinebreakbywordwrapping; yearlyaudio.titlelabel.numberoflines = 2; [yearlyaudio.titlelabel settextalignment: nstextalignmentcenter]; [yearlyaudio settitleedgeinsets:uiedgeinsetsmake(60, 10, 10, 10)]; [yearlyaudio.titlelabel setfont:[uifont systemfontofsize:14.0]]; yearlyaudio.frame=cgrectmake(160, 50, 140, 110); yearlyaudio.layer.cornerradius=5; yearlyaudio.backgroundcolor=[uicolor colorwithred:16.0f/255.0f green:144.0f/255.0f blue:209.0f/255.0f alpha:1.0]; [self.view addsubview:yearlyaudio]; yearlyaudioimage=[[uiimageview alloc]initwithframe:cgrectmake(45, 10, 48, 48)]; yearlyaudioimage.image=[uiimage imagenamed:@"48*48.png"]; [yearlyaudio addsubview:yearlyaudioimage]; yearlyaudio.autoresizingmask = uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblerightmargin |uiviewautoresizingflexiblebottommargin | uiviewautoresizingflexibletopmargin; adbannerview *adview = [[adbannerview alloc] initwithframe:cgrectzero]; adview.frame=cgrectmake(0, 410, 320, 40); adview.delegate=self; [self.view addsubview:adview]; } }
Comments
Post a Comment