[英]UIActivityIndicatorView in UITableView section header disappears on orientation change
[英]iOS - UILabel + UIActivityIndicatorView inside UITableView section header
在“設置”應用中,當您選擇Wi-Fi網絡時,您可以看到一個表格視圖,該視圖在標簽后面有一個標簽和一個活動指示器。 是否有一些預定義的方法來創建這樣的UI。 或者唯一的方法是使用一些創建標簽和微調器的代碼實現tableView:viewForHeaderInSection
,計算標簽寬度並將微調器放在它后面?
是的,你有正確的方法! 創建帶標簽的標題視圖,並在其后面放置一個UIActivityIndicator。 計算非常簡單:
UILabel* myLabel = ...;
CGSize size = [myLabel.text sizeWithFont: myLabel.font];
UIActivityIndicator* indicatorView = ...;
indicatorView.center = CGPointMake(size.width + indicatorView.frame.size.width, myLabel.center.y);
UITableViewCell.accessoryView,創建一個UIActivityIndicator實例並分配給它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.