ios - Centering image with Title Label in Navigation Bar -


i adding custom title label , custom image navigation bar. can correctly add title label in position want cannot center horizontally image label. adding screenshot , code use can help.

enter image description here enter image description here

-(void)addiconinnavbar {     cgsize imagesize = cgsizemake(lblheight, lblheight);     cgfloat marginx = (self.navigationcontroller.navigationbar.frame.size.width) - (imagesize.width / 2);     cgfloat marginy = (self.navigationcontroller.navigationbar.frame.size.height / 2) - (imagesize.height / 2);      imageview.frame = cgrectmake(marginx, marginy , imagesize.width, imagesize.height);     [self.navigationcontroller.navigationbar addsubview:imageview];  } 

please update centerx as

cgfloat marginx = (self.navigationcontroller.navigationbar.frame.size.width - imagesize.width) / 2; 

or

cgfloat marginx = (self.navigationcontroller.navigationbar.frame.size.width/2) - (imagesize.width / 2); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -