2012-10-20 23 views
13

Mam widok, który pojawia się w środku nadrzędnego trybu portretu portretowego, której maski automatycznej maski powinienem używać, aby był wyświetlany również w środku w trybie poziomym. Jego rozmiar powinien pozostać taki sam. Po prostu chcę, aby jego pochodzenie przesunęło się automatycznie w punkcie, tak aby pojawiło się w środku. Tak, proszę o pomoc?Właściwą automatyczną maską resursową

dałem

[parentView setAutoResizesSubview:YES]; 

parentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 

Odpowiedz

25
// horizontal 
childView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 

// vertical 
childView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 

// both 
childView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 
+1

yo dzięki człowiek ... –

0
If you are using swift: 
// horizontal 
childView.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin] 
// vertical 
childView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin] 
// both 
childView.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin, .flexibleTopMargin, .flexibleBottomMargin] 
3

Swift 3:

childView.translatesAutoresizingMaskIntoConstraints = false 

childView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin] 
Powiązane problemy