In the use of Uiimageview , It is sometimes necessary to set the fill mode of the contents of the picture in the code.
in order to facilitate the future work convenient to find use , the various models are now tested as follows
Test picture content fill mode static int a;-(void) test1{self.imageV.image = [UIImage imagenamed:@ "aa.jpg"]; Change the fill mode of internal content self.imageV.contentMode = A; Display mode text UILabel *lab = [[UILabel alloc]initwithframe:cgrectmake (0, 300, 375, 100)]; Nsarray *arr = @[@ "Uiviewcontentmodescaletofill",//stretch adaptive fills the entire view @ "UIVIEWC Ontentmodescaleaspectfit ",//Adaptive proportional size display @" Uiviewcontentmodescaleaspectfill ",//Original size display @ "Uiviewcontentmoderedraw",//Redraw @ "Uiviewcontentmodecenter" when size changes,// @ "Uiviewcontentmodetop",//Top @ "Uiviewcontentmodebottom", Bottom @ "Uiviewcontentmodeleft",//center sticker left @ "Uiviewcontentmoderight ",//center sticker Right @" Uiviewcontentmodetopleft ",//paste on top left @" Uiviewconte Ntmodetopright ",//Paste Right @ "uiviewcontentmodebottomleft",//paste left down @ "Uiviewcontentmodebottomright" ,//paste right down]; Lab.text = arr[a++]; Lab.font = [Uifont systemfontofsize:20]; [Self.lab Removefromsuperview]; [Self.imagev Addsubview:lab]; Self.lab = Lab; NSLog (@ "%s mode%d", __func__,a); if (a = =) A = 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
iOS Development-Control Contentmode Code change fill Pattern Summary