下拉刷新可自行封裝在 UIScrollView 的分類中。核心概念是在頂部加入 headerView,在底部加入 footerView,並監聽 contentOffset 變化。

headerView 的 frame 初始 y 為負值;當使用者下拉達到門檻,就觸發刷新並調整 contentInset,讓 header 保持可見。

刷新結束後,停止動畫並還原 contentInset。footerView 同理,用於上拉加載更多。

自定義 headerView 可依 contentOffset 改變箭頭或文字。實作時會遇到回彈抖動等問題,需要仔細處理狀態與動畫時機。
