導航:首頁 > 文字圖片 > button圖片和文字

button圖片和文字

發布時間:2022-10-14 23:24:42

⑴ 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;

}

閱讀全文

與button圖片和文字相關的資料

熱點內容
寒假通知圖片大全簡單又漂亮 瀏覽:863
放大鏡圖片怎麼下載 瀏覽:592
女卷短發發型圖片 瀏覽:632
小豬花衣服圖片 瀏覽:774
圖片大全唯美霸氣女生 瀏覽:512
夏季怎麼畫圖片新聞 瀏覽:693
青春頭像高清圖片大全 瀏覽:292
初一女生內衣吊帶圖片 瀏覽:29
男生留中分發型圖片 瀏覽:137
三七可愛卡通圖片 瀏覽:791
如何將圖片截圖到word文檔 瀏覽:434
暗系簡約男生動漫圖片 瀏覽:744
孫尚空圖片高清 瀏覽:838
短發女孩哭泣圖片大全 瀏覽:837
魔法世界可愛兔子圖片 瀏覽:903
故宮英國高清圖片 瀏覽:503
word加圖片水印怎麼是白色 瀏覽:713
哭的男生動作圖片 瀏覽:427
word文檔的圖片里畫圖形 瀏覽:675
傷感的圖片哭了女生 瀏覽:564