(中行雷威2020.05.23)
(同一個世界,同一個夢想,交流學習C++Builder and Delphi XE10,傳承c++builder and Delphi的魅力!歡迎各地朋友加入我的QQ羣484979943,進羣密碼“BCB”,同時也請將該羣號廣爲宣傳,希望能夠廣集各方高手,共同進步。如需下載開發工具及源代碼請加入我的QQ羣。)
【閱讀倡議】
1、有問題請留言;
2、沒問題請點贊;
3、看連載請加羣;
4、下源碼請加羣;
【開發工具】
1、C++Builder and Delphi 10.3.3
2、FMSoft_uniGUI_Complete_Professional_1.70.0.1531(正版)
本人主筆的國內第一本uniGUI教學案例代碼已誕生,分爲cbuilder和delphi兩個版本,買代碼送教程,需要的朋友可以加入我的QQ技術交流羣484979943給我(羣主)留言。資料簡介:
Font Awesome是一套絕佳的圖標字體庫和CCS框架,爲我們提供了一套可以縮放的矢量圖標,我們可以用CSS所提供的所有特性對它們進行設置,包括字體大小、顏色、陰影或者其它任何支持的效果,有了它,我們就可以爲我們的UniGUI項目的各個控件的標籤配置各種各樣的圖標字體。圖標字體:即圖片樣式的字體,和字體具有一樣的屬性,表現出來的卻是小圖片。
1、佈局
創建一個項目,在MainmForm上添加一個UnimBitBtn、一個UnimLabel、一個UnimTabPanel、一個UnimSegmentedButton,爲UnimTabPanel1創建兩個UnimTabSheet,爲UnimSegmentedButton1創建三個UnimButtonItem。
【注意】如果是電腦版項目,請先將UniLabel的TextConversion屬性設置爲txtHTML。
2、功能
爲每個控件的Caption設置一個圖標字體,讓其能夠關聯圖標字體庫,顯示一個漂亮的小圖標,以提升我們的UniGUI項目的視覺效果。
3、代碼
1)、下載免費的FontAweSome離線圖標庫,下載地址爲 https://fontawesome.com/download ,選擇FreeForWeb
2)、將下載的圖標字體包fontawesome-free-5.13.0-web.zip複製到你的項目的Win32\Debug\files目錄下,並解壓縮。
3)、打開UniServerModule窗口,配置其CustomFiles屬性,增加一行語句引用圖標字體包,如下所示:
<link rel="stylesheet" href="files/fontawesome-free-5.13.0-web/css/all.css">
4)、圖標字體使用方法
“fas”表示圖標字體的類別,“fa-bell”表示圖標字體的名稱,圖標字體的各種Style類別、StylePrefix前綴名、Example應用舉例和對應的Rendering例圖如下圖所示:
5)、選擇可用的圖標字體樣式https://fontawesome.com/icons?d=listing&s=regular&m=free
打開圖標字體樣式網頁後,在左側選擇“Free”、“Solid”後右側將出現可用的免費的Solid類別的圖標字體,如果想用第二個圖標“address-book”,則在使用時要在該名稱前增加“fa-”來引用圖標字體,即:
Unimlabel1.caption:='<i class="fas fa-address-book" style=color:red></i>字體圖標';
6)、MainmForm的OnShow代碼
Delphi版:
procedure TMainmForm.UnimFormShow(Sender: TObject);
begin
UnimSegmentedButton1.Items[0].Caption := '<i class="fas fa-bell" style=color:tomato></i>第一按鈕';
UnimSegmentedButton1.Items[1].Caption := '<i class="fas fa-angry" style=color:tomato></i>第二按鈕';
UnimSegmentedButton1.Items[2].Caption := '<i class="fas fa-envelope" style=color:tomato></i>第三按鈕';
Unimlabel1.caption:='<i class="fas fa-bell" style=color:red></i>字體圖標';
UnimBitBtn1.caption:='<i class="fas fa-bell" style=color:green></i>字體圖標';
UnimTabSheet1.caption:='<i class="fas fa-adjust" style=color:yellow></i>字體圖標';
UnimTabSheet2.caption:='<i class="fab fa-angellist" style=color:green></i>字體圖標';
end;
cBuilder版:
void __fastcall TMainmForm::UnimFormShow(TObject *Sender)
{
UnimSegmentedButton1->Items->Items[0]->Caption = "<i class=\"fas fa-bell\" style=color:tomato></i>第一按鈕";
UnimSegmentedButton1->Items->Items[1]->Caption = "<i class=\"fas fa-angry\" style=color:tomato></i>第二按鈕";
UnimSegmentedButton1->Items->Items[2]->Caption = "<i class=\"fas fa-envelope\" style=color:tomato></i>第三按鈕";
UnimLabel1->Caption="<i class=\"fas fa-bell\" style=color:red></i>字體圖標";
UnimBitBtn1->Caption="<i class=\"fas fa-bell\" style=color:green></i>字體圖標";
UnimTabSheet1->Caption="<i class=\"fas fa-adjust\" style=color:yellow></i>字體圖標";
UnimTabSheet2->Caption="<i class=\"fab fa-angellist\" style=color:green></i>字體圖標";
}
4、效果