⑴ iOS 调整UIButton 图片(imageView)与文字(titleLabel)的位置
UIButton可以同时设置Title和Image,UIButton有两个属性:titleEdgeInsets(top,left,bottom,right)和imageEdgeInsets(top,left,bottom,right),通过设置这两个,就可以实现所有需要的Button的样式
UIButton 的 默认状态下imageEdgeInsets = UIEdgeInsetsMake(0,0,0,0);titleEdgeInsets = UIEdgeInsetsMake(0,0,0,0); 图片在左文字在右,而且整体水平和垂直居中 。比如下面这个图文按钮:
为了最美观一点,可以设置图标与文字间距 。如下图:
设置图片在右文字在左:
设置图片在上,文字在下:
设置图片左对齐:
设置文字右对齐:
设置文字左对齐,图片右对齐:
⑵ asp.net 怎么做一个带图片和文字的button
<asp:ImageButtonID="btnSubmit"
runat="server"ImageUrl="http://www..com/img/_sylogo1.gif"/>效果
你可以定义宽高,和图片url。或者直接用
<asp:ButtonID="btnLogin"runat="server"Text="登录"
CssClass="btn_5"/>写在样式里边
.btn_b1{width:155px;height:90px;line-height:60px;border:0px;font-size:14px;text-align:center;color:#fff;background:url(../images/btn_b1.png)no-repeat;cursor:pointer;display:inline-block;text-decoration:none;font-weight:bold;}
.btn_b1:hover{color:#fff;text-decoration:none;}
⑶ 自定义BUTTON里面放一个图片和一个字符串
用TextView吧,能实现所有button的功能。而且设置文字和图片共存也简单,和setCompoundDrawables都可以实现。
⑷ asp.net 怎么做一个带图片和文字的button
<asp:ImageButtonID="btnSubmit" runat="server"ImageUrl="http://www..com/img/_sylogo1.gif"/>效果
你可以定义宽高,和图片url。或者直接用
<asp:ButtonID="btnLogin"runat="server"Text="登录" CssClass="btn_5"/>写在样式里边
.btn_b1{width:155px;height:90px;line-height:60px;border:0px;font-size:14px;text-align:center;color:#fff;background:url(../images/btn_b1.png)no-repeat;cursor:pointer;display:inline-block;text-decoration:none;font-weight:bold;}
.btn_b1:hover{color:#fff;text-decoration:none;}
⑸ 如何在css中设置按钮button中包含图片文字对齐方式
align="middle" ,你可以通过这个属性来调试一下,看看是剧中还居左或右适合你
⑹ 详解button设置文字和图片
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.backgroundColor = kRandomColor;
button.tag = i + addTag;
button.frame = CGRectMake(kScreenWidth / 3 * i, 0, kScreenWidth / 3, 50);
//首先设置需要显示的文字和图片
[button setTitle:titleArray[i] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setImage:image forState:UIControlStateNormal];
//再将文字和图片进行偏移处理
//这里+3和-3是需要文字和图片有一定的间隔
[button setTitleEdgeInsets:UIEdgeInsetsMake(0, -image.size.width, 0, image.size.width)];
[button setImageEdgeInsets:UIEdgeInsetsMake(0, button.titleLabel.bounds.size.width+3, 0, -button.titleLabel.bounds.size.width-3)];
//自己去将图片进行修改
- (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size{
// 创建一个bitmap的context
// 并把它设置成为当前正在使用的context
UIGraphicsBeginImageContext(size);
// 绘制改变大小的图片
[img drawInRect:CGRectMake(0, 0, size.width, size.height)];
// 从当前context中创建一个改变大小后的图片
UIImage* scaledImage = ();
// 使当前的context出堆栈
UIGraphicsEndImageContext();
// 返回新的改变大小后的图片
return scaledImage;
}