zoukankan      html  css  js  c++  java
  • XCode5 使用AutoLayout情况下改变控件的 方法

    [self.viewButtonsetTranslatesAutoresizingMaskIntoConstraints:NO];

        //[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.viewButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];

        //改变 高度

        [self.viewaddConstraint:[NSLayoutConstraint

                                  constraintWithItem:self.viewButton

                                  attribute:NSLayoutAttributeHeight

                                  relatedBy:NSLayoutRelationEqual

                                  toItem:self.view

                                  attribute:NSLayoutAttributeHeight

                                  multiplier:0.3

                                  constant:0]];

        [self.viewButtonaddObserver:selfforKeyPath:@"bounds"options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitialcontext:nil];//注册kvo监听bounds的变化

        

    }

    //kvo回调

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

    {

        if (object == self.viewButton && [keyPath isEqualToString:@"bounds"])

        {

    //        [self.viewButton setTitle:NSStringFromCGSize(self.viewButton.bounds.size) forState:UIControlStateNormal];

            

            NSLog(@"");

        }

    }

  • 相关阅读:
    Java web 会话技术 cookie与session
    Spring bean的bean的三种实例化方式
    Spring基础篇——通过Java注解和XML配置装配bean(转载)
    Spring的核心api和两种实例化方式
    Spring 7种事务传播类型
    leetcode 697
    leetcode 387
    Spring_002 依赖注入方式实现
    Spring_第一个Spring入门案例IOC
    谈谈对Spring IOC的理解(转载)
  • 原文地址:https://www.cnblogs.com/chenhaosuibi/p/3520304.html
Copyright © 2011-2022 走看看