Skip to content

Commit fd02339

Browse files
author
Diogo Autilio
committed
Fix background rotation with new window
1 parent 2a347c3 commit fd02339

1 file changed

Lines changed: 32 additions & 18 deletions

File tree

SCLAlertView/SCLAlertView.m

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -239,30 +239,44 @@ - (void)viewWillLayoutSubviews
239239
}
240240
}
241241

242-
// Set new background frame
243-
CGRect newBackgroundFrame = self.backgroundView.frame;
244-
newBackgroundFrame.size = sz;
245-
self.backgroundView.frame = newBackgroundFrame;
246-
247-
// Set new main frame
248-
CGRect r;
249-
if (self.view.superview != nil)
242+
if(!_usingNewWindow)
250243
{
251-
// View is showing, position at center of screen
252-
r = CGRectMake((sz.width-_windowWidth)/2, (sz.height-_windowHeight)/2, _windowWidth, _windowHeight);
244+
// Set new background frame
245+
CGRect newBackgroundFrame = self.backgroundView.frame;
246+
newBackgroundFrame.size = sz;
247+
self.backgroundView.frame = newBackgroundFrame;
248+
249+
// Set new main frame
250+
CGRect r;
251+
if (self.view.superview != nil)
252+
{
253+
// View is showing, position at center of screen
254+
r = CGRectMake((sz.width-_windowWidth)/2, (sz.height-_windowHeight)/2, _windowWidth, _windowHeight);
255+
}
256+
else
257+
{
258+
// View is not visible, position outside screen bounds
259+
r = CGRectMake((sz.width-_windowWidth)/2, -_windowHeight, _windowWidth, _windowHeight);
260+
}
261+
262+
// Set frames
263+
self.view.frame = r;
264+
_contentView.frame = CGRectMake(0.0f, kCircleHeight / 4, _windowWidth, _windowHeight);
265+
_circleViewBackground.frame = CGRectMake(_windowWidth / 2 - kCircleHeightBackground / 2, kCircleBackgroundTopPosition, kCircleHeightBackground, kCircleHeightBackground);
266+
_circleIconImageView.frame = CGRectMake(kCircleHeight / 2 - _circleIconHeight / 2, kCircleHeight / 2 - _circleIconHeight / 2, _circleIconHeight, _circleIconHeight);
253267
}
254268
else
255269
{
256-
// View is not visible, position outside screen bounds
257-
r = CGRectMake((sz.width-_windowWidth)/2, -_windowHeight, _windowWidth, _windowHeight);
270+
CGFloat x = (sz.width - _windowWidth) / 2;
271+
CGFloat y = (sz.height - _windowHeight - (kCircleHeight / 8)) / 2;
272+
273+
_contentView.frame = CGRectMake(x, y, _windowWidth, _windowHeight);
274+
y -= kCircleHeightBackground * 0.6f;
275+
x = (sz.width - kCircleHeightBackground) / 2;
276+
_circleViewBackground.frame = CGRectMake(x, y, kCircleHeightBackground, kCircleHeightBackground);
277+
_circleIconImageView.frame = CGRectMake(kCircleHeight / 2 - _circleIconHeight / 2, kCircleHeight / 2 - _circleIconHeight / 2, _circleIconHeight, _circleIconHeight);
258278
}
259279

260-
// Set frames
261-
self.view.frame = r;
262-
_contentView.frame = CGRectMake(0.0f, kCircleHeight / 4, _windowWidth, _windowHeight);
263-
_circleViewBackground.frame = CGRectMake(_windowWidth / 2 - kCircleHeightBackground / 2, kCircleBackgroundTopPosition, kCircleHeightBackground, kCircleHeightBackground);
264-
_circleIconImageView.frame = CGRectMake(kCircleHeight / 2 - _circleIconHeight / 2, kCircleHeight / 2 - _circleIconHeight / 2, _circleIconHeight, _circleIconHeight);
265-
266280
{
267281
// Text fields
268282
CGFloat y = (_labelTitle.text == nil) ? (kCircleHeight - 20.0f) : 74.0f;

0 commit comments

Comments
 (0)