pujiaxin33 / JXSegmentedView

A powerful and easy to use segmented view (segmentedcontrol, pagingview, pagerview, pagecontrol, categoryview) (腾讯新闻、今日头条、QQ音乐、网易云音乐、京东、爱奇艺、腾讯视频、淘宝、天猫、简书、微博等所有主流APP分类切换滚动视图)
MIT License
2.7k stars 372 forks source link

SegmentedTitleCell 有警告 #209

Closed DNC-7 closed 5 months ago

DNC-7 commented 2 years ago

Xcode 提示优化 Optimization Opportunities: The layer is using a simple layer with background color set as a mask. Instead, use a container layer of the same frame and cornerRadius as the mask, but with masksToBounds set to YES.

viihua commented 2 years ago

image 注释掉 不使用就好了

viihua commented 2 years ago

或者Podfile里添加: post_install do |installer| find_and_replace("Pods/JXSegmentedView/Sources/Title/JXSegmentedTitleCell.swift", " maskTitleLabel.isHidden = true", " maskTitleLabel.isHidden = true\n maskTitleLabel.layer.mask = nil") end

注入代码到指定文件

def find_and_replace(dir, findstr, replacestr) Dir[dir].each do |name| FileUtils.chmod("+w", name) #add text = File.read(name) replace = text.gsub(findstr,replacestr) if text != replace puts "Fix: " + name File.open(name, "w") { |file| file.puts replace } STDOUT.flush end end Dir[dir + '*/'].each(&method(:find_and_replace)) end

DNC-7 commented 2 years ago

image 注释掉 不使用就好了

好的,感谢回复

viihua commented 2 years ago

image 注释掉 不使用就好了

好的,感谢回复

不破坏原有代码结构的话 就在第141行的maskTitleLabel.isHidden = true 后面加 maskTitleLabel.layer.mask = nil,如果是使用pod的话就用我以下的文本放入Podfile,前面那个有点小问题,一个空格都不能少哦,字符串查找替换的:

post_install do |installer| find_and_replace("Pods/JXSegmentedView/Sources/Title/JXSegmentedTitleCell.swift", " maskTitleLabel.isHidden = true\n titleLabel.layer.mask = nil"," maskTitleLabel.isHidden = true\n maskTitleLabel.layer.mask = nil\n titleLabel.layer.mask = nil") end

注入代码到指定文件

def find_and_replace(dir, findstr, replacestr) Dir[dir].each do |name| FileUtils.chmod("+w", name) #add text = File.read(name) replace = text.gsub(findstr,replacestr) if text != replace puts "Fix: " + name File.open(name, "w") { |file| file.puts replace } STDOUT.flush end end Dir[dir + '*/'].each(&method(:find_and_replace)) end