7秒丶记忆吧 关注:2贴子:59
  • 2回复贴,共1

手机开热点的UI调整

只看楼主收藏回复

解决方法:通知----接到通知调整各个UI
tableBar特殊 只需在tabBarCV的viewdidload里 [self layoutControllerSubViews];
- (void)layoutControllerSubViews
{
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
NSInteger addHeight = screenRect.origin.y-20;/*差为状态栏增量的高度*/
NSMutableDictionary *notifyInfo = [[NSMutableDictionary alloc] init];
CGRect rectView;
if (screenRect.origin.y > 20) {
rectView = CGRectMake(0,0,screenRect.size.width,addHeight + screenRect.size.height /*- KTabBarHeight*/);
tabBar.frame=CGRectMake(0,
addHeight + screenRect.size.height - KTabBarHeight,
screenRect.size.width,
KTabBarHeight);
[notifyInfo setValue:@"open" forKey:@"hot"];
}
else {
rectView = CGRectMake(0, 0, KDeviceWidth, self.view.frame.size.height /*- KTabBarHeight*/);
tabBar.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.size.height-KTabBarHeight, self.view.frame.size.width, KTabBarHeight);
[notifyInfo setValue:@"close" forKey:@"hot"];
}
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:HotChang
object:nil
userInfo:notifyInfo];
各个UI注册通知并调整UI


IP属地:山东1楼2016-03-15 16:28回复
    以上是热点开与不开切换的时候
    第二种情况是一直开着的时候:
    if ([[UIScreen mainScreen] applicationFrame].origin.y > 20)
    {
    UI的frame
    }


    IP属地:山东2楼2016-03-15 16:30
    回复
      例子:
      各个VC的通知
      -(void)hotChang:(NSNotification *)notification{
      NSDictionary *eventInfo = [notification userInfo];
      NSString *hotType = [eventInfo objectForKey:@"hot"];
      if ([hotType isEqualToString:@"open"]) {
      btnRecharge.frame = CGRectMake(btnRechargeFrame.origin.x, btnRechargeFrame.origin.y - HOT_HEIGHT, btnRechargeFrame.size.width, btnRechargeFrame.size.height);
      tableFreetime.frame = CGRectMake(freeTabVCFrame.origin.x, freeTabVCFrame.origin.y , freeTabVCFrame.size.width, freeTabVCFrame.size.height- HOT_HEIGHT);
      grayLImageView.frame = CGRectMake(grayLImageViewFrame.origin.x, grayLImageViewFrame.origin.y - HOT_HEIGHT, grayLImageViewFrame.size.width, grayLImageViewFrame.size.height);
      }else{
      btnRecharge.frame = btnRechargeFrame;
      tableFreetime.frame = freeTabVCFrame;
      grayLImageView.frame = grayLImageViewFrame;
      }
      }


      IP属地:山东3楼2016-03-15 16:31
      回复