in several places in application 0 frame sizes used frame. impacted me when creating round objects doing cornerradius of size/2
.
for example, in xcode 7 worked fine:
class avataruibutton: uibutton { required init?(coder adecoder: nscoder) { super.init(coder: adecoder) layer.maskstobounds = true layer.cornerradius = bounds.size.width / 2 } }
but in xcode 8 have this:
class avataruibutton: uibutton { override var bounds: cgrect { didset { layer.cornerradius = bounds.size.width / 2 }} required init?(coder adecoder: nscoder) { super.init(coder: adecoder) self.layer.maskstobounds = true } }
in example, change arguably better/more obvious. have situation less isolated involving 0 frame on tableheaderview xcode 8.
i'm looking release notes, mailing list discussion, or similar discusses change in ordering of frame size determination can figure out changed , how can fix it.
in xcode 8, apple :
xcode 8 removes ability configure views without constraints frame varying per size class. views without constraints may different after compiling xcode 8 when switching size classes @ runtime. going forward, use constraints , autoresizing masks device bar achieve desired layout. (25894544)
in previous versions of xcode, used define design on viewdidload. here, different elements not created (and constraints too), view created size in storyboard.
now, in xcode 8, cannot anymore. need have constraints because frame not initialize (that's why of have these values frame size : 0, 0, 1000, 1000). example, make in viewdidappear , work fine. but, see @ first button without corner radius few times.
so, can use function (here in objective c) (where want, in loading function) :
[self performselector:@selector(setcornertomybutton) withobject:null afterdelay:0];
you can pu delay want, 0 works.
and change radius in function example :
- (void) setcornertomybutton { //do want... layer.maskstobounds = true layer.cornerradius = bounds.size.width / 2 }
hope you.
Comments
Post a Comment