ios - rounded navigation bar image iphone sdk -
i trying set navigation bar's titleview
rounded image. similar profile images see in messaging applications.
i believe should able create rounded scaled down image doing following:
uiimageview* profileimageview = [[uiimageview alloc] initwithimage:logoimage]; [profileimageview setframe:cgrectmake(0, 0, 30, 30)]; //profileimageview.contentmode = uiviewcontentmodescaleaspectfit; // xxx contentmode commented out because enabling causes rounded corners have no effect? profileimageview.layer.cornerradius = 15; profileimageview.layer.maskstobounds = yes; profileimageview.clipstobounds = yes; self.navigationitem.titleview = profileimageview;
this appears create image desire split second when load emulator, image appears in top left corner of screen , snaps center of navigation bar. once @ center of navigation bar rescales take entire space of navigation bar instead of remaining small circle. missing? seems must need disable ever mechanism causing image scale fill entire navigation bar.
just add contain view
uiview * containview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 30, 30)]; uiimageview* profileimageview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"image.jpeg"]]; [profileimageview setframe:cgrectmake(0, 0, 30, 30)]; profileimageview.layer.cornerradius = 15; profileimageview.layer.maskstobounds = yes; profileimageview.clipstobounds = yes; [containview addsubview:profileimageview]; self.navigationitem.titleview = containview;
screenshot
Comments
Post a Comment