答案1
有几个主题在框架标题中确实有渐变,例如华沙主题:
\documentclass{beamer}
\usetheme{Warsaw}
\usecolortheme{beaver}
\setbeamercolor{frametitle}{bg=lightgray}
\setbeamercolor{frametitle right}{bg=white}
\makeatletter
\setbeamertemplate{frametitle}{%
\nointerlineskip%
\vskip-2pt%
\hbox{\leavevmode
\advance\beamer@leftmargin by -12bp%
\advance\beamer@rightmargin by -12bp%
\beamer@tempdim=\textwidth%
\advance\beamer@tempdim by \beamer@leftmargin%
\advance\beamer@tempdim by \beamer@rightmargin%
\hskip-\Gm@lmargin\hbox{%
\setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{.8\paperwidth}%
\vbox{}\vskip-.75ex%
\leftskip0.3cm%
\rightskip0.3cm plus1fil\leavevmode
\usebeamercolor[fg]{frametitle}\usebeamerfont{frametitle}\strut\insertframetitle\strut\par%
\ifx\insertframesubtitle\@empty\else%
{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
\fi%
\nointerlineskip
\vbox{}%
\end{minipage}\begin{minipage}[b][.7cm][t]{.2\paperwidth}
\hfill\includegraphics[height=0.7cm]{example-image-duck}\quad\mbox{}
\end{minipage}}%
\beamer@tempdim=\ht\beamer@tempbox%
\advance\beamer@tempdim by 2pt%
\begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
\begin{pgfscope}
\pgfsetfillcolor{beamer@safeblack}%
\pgfpathrectangle{\pgfpoint{0pt}{-4pt}}{\pgfpoint{\paperwidth}{8pt}}%
\pgfsetfading{beamer@topshadowmask}{}%
\pgfusepath{fill}%
\end{pgfscope}
\begin{pgfscope}
\usebeamercolor{frametitle right}%
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}%
\pgfusepath{clip}%
\pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}%
\end{pgfscope}
\end{pgfpicture}
\hskip-\paperwidth%
\box\beamer@tempbox%
}%
\hskip-\Gm@rmargin%
}%
\vskip-2pt
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{title}
eee
\end{frame}
\end{document}