開始的時(shí)候按鈕事件中,可能寫的是這樣一段代碼:
if (isexpand) {
[lblbrief setnumberoflines:2];
lblbrief.text = [stringutil substring:strbrief andsublength:90];
[btnbrief setimage:[uiimage imagenamed:@detailbriefdown] forstate:uicontrolstatenormal];
[btnbrief setimage:[uiimage imagenamed:@detailbriefdown] forstate:uicontrolstatehighlighted];
}else{
[lblbrief setnumberoflines:0];
lblbrief.text = strbrief;
[btnbrief setimage:[uiimage imagenamed:@detailbriefup] forstate:uicontrolstatenormal];
[btnbrief setimage:[uiimage imagenamed:@detailbriefup] forstate:uicontrolstatehighlighted];
}
可以通過setnumberoflines:0,來讓概述的所以內(nèi)容顯示出來,但如果,不計(jì)算所要顯示全部?jī)?nèi)容的總高度,label的寬高是不會(huì)自動(dòng)增大的。
else{
[lblbrief setnumberoflines:0];
lblbrief.text = strbrief;
cgsize constraint = cgsizemake(self.view.frame.size.width - (15 * 2), 20000.0f);
cgsize size = [strbrief sizewithfont:[uifont systemfontofsize:10]constrainedtosize:constraint linebreakmode:uilinebreakmodewordwrap];
[brief setframe:cgrectmake(15,160,size.width,size.height)];
[btnbrief setimage:[uiimage imagenamed:@detailbriefup]forstate:uicontrolstatenormal];
[btnbrief setimage:[uiimage imagenamed:@detailbriefup]forstate:uicontrolstatehighlighted];
}
更多信息請(qǐng)查看IT技術(shù)專欄