标签:内容模型 ted UI enter uibutton uiimage 边框 target tom
//1.添加按钮 UIButton *nameView=[UIButton buttonWithType:UIButtonTypeCustom]; //nameView.backgroundColor=[UIColor redColor]; [nameView setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg"] forState:UIControlStateNormal]; [nameView setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg_highlighted"] forState:UIControlStateHighlighted]; //设置按钮内部的左边箭头图片 [nameView setImage:[UIImage imageNamed:@"buddy_header_arrow"] forState:UIControlStateNormal]; [nameView setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; // //设置按钮的内容左对齐 // nameView.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft; // 设置按钮的内容左对齐 nameView.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; //设置按钮的内边距 nameView.titleEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 0); nameView.contentEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 0); [nameView addTarget:self action:@selector(nameViewClick) forControlEvents:UIControlEventTouchUpInside]; //设置按钮内部的imageView的内容模型为居中 nameView.imageView.contentMode=UIViewContentModeCenter; //超出边框的内容不需要裁剪 nameView.imageView.clipsToBounds=NO; [self.contentView addSubview:nameView]; self.nameView=nameView;
标签:内容模型 ted UI enter uibutton uiimage 边框 target tom
原文地址:http://www.cnblogs.com/liuwj/p/6496647.html