iDev/iOS Dev

iOS 8 Today Extension(Widget) 여백 없애는 방법

KraZYeom 2014. 10. 11. 20:00
반응형



iOS 8 Today Extension(Widget) 여백 없애는 방법

iOS 8이 나오면서 많은 앱들이 Today Extension(이하 Widget) 지원하기 시작했다. 하지만 왼쪽에 아이콘 만큼 여백이 있는 앱도 있고, 여백 없이 꽉차게 나오는 앱도 있다. 기본적으로 위젯을 구현하면 여백이 생긴다. 


https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/NotificationCenter.html 에 보면 아래와 같이 위젯의 뷰의 크기에 대한 내용이 나와있습니다.

Because space in the Today view is limited and the expected user experience is quick and focused, you shouldn’t create a widget that’s too big by default. On both platforms, a widget must fit within the width of the Today view, but it can increase in height to display more content.


아래 그림 처럼 아무런 설정을 하지 않고 빌드를 하면 여백이 생긴다.

여백없이 구현하는 방법은 간단하다. superview의 frame의 width를 수정하면된다. 

swift 버전은 알아서... -_ -;


- (void)viewWillAppear:(BOOL)animated {

  [super viewWillAppear:animated];

  CGRect frame = self.view.superview.frame;

  frame = CGRectMake(0,CGRectGetMinY(frame), CGRectGetWidth(frame) + CGRectGetMinX(frame), CGRectGetHeight(frame));

  self.view.superview.frame = frame;

}


이렇게 적용하면 아래 그림 처럼 꽉차게 나온다.



반응형