调节图片浏览菜单是否居中的问题

This commit is contained in:
bluesea 2024-04-29 17:19:13 +08:00
parent c2268c7228
commit 88b995b95a
4 changed files with 72 additions and 11 deletions

View File

@ -46,8 +46,8 @@
filePath = "SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift" filePath = "SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "131" startingLineNumber = "140"
endingLineNumber = "131" endingLineNumber = "140"
landmarkName = "init(menuWidth:arrow:datas:configures:dissMissCallback:)" landmarkName = "init(menuWidth:arrow:datas:configures:dissMissCallback:)"
landmarkType = "7"> landmarkType = "7">
<Locations> <Locations>
@ -664,5 +664,37 @@
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "2332D3C8-7CB7-4C2D-9D3C-D9A7D05737DE"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "171"
endingLineNumber = "171"
landmarkName = "init(menuWidth:arrow:datas:configures:dissMissCallback:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "02F226A8-01C1-4FB7-8724-3FB114CBBC79"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "169"
endingLineNumber = "169"
landmarkName = "init(menuWidth:arrow:datas:configures:dissMissCallback:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints> </Breakpoints>
</Bucket> </Bucket>

View File

@ -222,9 +222,14 @@ class CCSpatialPhotoDisplayController: BaseController {
self.navtionBar?.isHidden = false self.navtionBar?.isHidden = false
mTopImgView.isHidden = false mTopImgView.isHidden = false
edBtn?.isHidden = false edBtn?.isHidden = false
menuView.isLandspaceScreen = false
menuView.dismiss()
break break
case .landscapeLeft , .landscapeRight: case .landscapeLeft , .landscapeRight:
isLandscape = true isLandscape = true
menuView.isLandspaceScreen = true
menuView.dismiss()
print("Landscape ...") print("Landscape ...")
navtionBar?.snp.updateConstraints { make in navtionBar?.snp.updateConstraints { make in
make.top.equalToSuperview().offset(-30) make.top.equalToSuperview().offset(-30)
@ -245,6 +250,9 @@ class CCSpatialPhotoDisplayController: BaseController {
default: default:
print("Other") print("Other")
} }
let pointOnScreen = navtionImgView!.convert(CGPointMake(KScreenHeight*0.5, navtionImgView!.bottom), to: KWindow)
menuView.exUpdateArrowPointWithIsLandspace(pointOnScreen)
} }
@ -361,6 +369,12 @@ class CCSpatialPhotoDisplayController: BaseController {
} }
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
KAppDelegate?.allowRotation = false
self.setNeedsUpdateOfSupportedInterfaceOrientations()
}
override func viewDidDisappear(_ animated: Bool) { override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated) super.viewDidDisappear(animated)
let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_PhotoDisplayController) let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_PhotoDisplayController)

View File

@ -72,7 +72,16 @@ public class CCSpatialDisplayTypeView: UIView {
static let cellID:String = "CCSpatialDisplayTypeCellID" static let cellID:String = "CCSpatialDisplayTypeCellID"
private var myFrame:CGRect! //tableview frame private var myFrame:CGRect! //tableview frame
private var arrowView : UIView! = nil private var arrowView : UIView! = nil
var isLandspaceScreen = false {
didSet{
if isLandspaceScreen {
self.frame = CGRect(origin: .zero, size: CGSize(width: KScrH, height: KScrW))
}
else{
self.frame = UIScreen.main.bounds
}
}
}
var tableView:UITableView! = nil var tableView:UITableView! = nil
var isShowing:Bool = false// var isShowing:Bool = false//
@ -163,6 +172,10 @@ public class CCSpatialDisplayTypeView: UIView {
} }
func exUpdateArrowPointWithIsLandspace(_ point:CGPoint) {
arrowPoint = point
}
required public init?(coder aDecoder: NSCoder) { required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
@ -188,6 +201,8 @@ public class CCSpatialDisplayTypeView: UIView {
} }
} }
//MARK: - UI //MARK: - UI
func initViews() { func initViews() {
self.backgroundColor = UIColor.black.withAlphaComponent(popMenuOutAlpha) self.backgroundColor = UIColor.black.withAlphaComponent(popMenuOutAlpha)
@ -217,8 +232,8 @@ public class CCSpatialDisplayTypeView: UIView {
tableView.delegate = self tableView.delegate = self
tableView.dataSource = self tableView.dataSource = self
tableView.bounces = false tableView.bounces = false
UIView.animate(withDuration: 0.3) { UIView.animate(withDuration: 0.3) {[weak self] in
self.addSubview(self.tableView) self?.addSubview((self?.tableView)!)
} }
// //
@ -238,14 +253,14 @@ public class CCSpatialDisplayTypeView: UIView {
if arrowPoint.x <= popMenuMargin { if arrowPoint.x <= popMenuMargin {
arrowPoint.x = popMenuMargin arrowPoint.x = popMenuMargin
} }
if arrowPoint.x >= KScrW - popMenuMargin{ if arrowPoint.x >= (isLandspaceScreen ? KScrH : KScrW) - popMenuMargin{
arrowPoint.x = KScrW - popMenuMargin arrowPoint.x = (isLandspaceScreen ? KScrH : KScrW) - popMenuMargin
} }
var originalPoint = CGPoint.zero var originalPoint = CGPoint.zero
// //
var arrowMargin:CGFloat = popMenuMargin var arrowMargin:CGFloat = popMenuMargin
if arrowPoint.x < KScrW/2{ if arrowPoint.x < (isLandspaceScreen ? KScrH : KScrW)/2{
if (arrowPoint.x > myFrame.width/2) { if (arrowPoint.x > myFrame.width/2) {
arrowMargin = myFrame.width/2 arrowMargin = myFrame.width/2
originalPoint = CGPoint(x: arrowPoint.x - myFrame.width/2, y: arrowPoint.y+arrowViewHeight) originalPoint = CGPoint(x: arrowPoint.x - myFrame.width/2, y: arrowPoint.y+arrowViewHeight)
@ -256,9 +271,9 @@ public class CCSpatialDisplayTypeView: UIView {
}else{ }else{
if (KScrW-arrowPoint.x) < myFrame.width/2{ if ((isLandspaceScreen ? KScrH : KScrW)-arrowPoint.x) < myFrame.width/2{
arrowMargin = (myFrame.width - KScrW + arrowPoint.x ) arrowMargin = (myFrame.width - (isLandspaceScreen ? KScrH : KScrW) + arrowPoint.x )
originalPoint = CGPoint(x: KScrW-popMenuMargin-myFrame.width, y: arrowPoint.y+arrowViewHeight) originalPoint = CGPoint(x: (isLandspaceScreen ? KScrH : KScrW)-popMenuMargin-myFrame.width, y: arrowPoint.y+arrowViewHeight)
}else{ }else{