#define LINEHEIGHT 44.0
#define TEXTTAG 10
#import "WViewController.h"
@interface WViewController ()
@end
@implementation WViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(IBAction)deleteLast
{
UIView* lastview = [self.view.subviews lastObject];
CGRect rect = lastview.frame;
rect.origin.x = self.view.frame.size.width;
[UIView animateWithDuration:0.5f animations:^{
[lastview setFrame:rect];
} completion:^(BOOL finished) {
[lastview removeFromSuperview];
_removeIt.enabled = [self.view.subviews count] > 3;
}];
}
- (IBAction)newtext
{
UIView* view = [self.view.subviews lastObject];
CGFloat y ;
// xcode 5.1中 默认会从中添加两个view 记住用法
[self.view.subviews count] == 3 ?( y = 44 ):( y = (view.frame.origin.y + view.frame.size.height +1 ));
C
iOS study Day 21-UIView 如何实现view的嵌套
最新推荐文章于 2018-01-12 15:36:09 发布
本文探讨了如何在iOS应用中实现UIView的嵌套,通过示例代码展示了如何动态添加、删除和布局子视图。同时,文章还涉及到如何设置UILabel和UIButton,并响应点击事件,为开发者提供了一个实用的iOS视图操作指南。
摘要由CSDN通过智能技术生成