0

SwiftUI seems to have good features, but only works on MacOS 1.15 and newer. Is there a framework for MacOS that is efficient, and shares the capabilities of SwiftUI. Well technically, if I put everything in the draw() method of an NSView, it can in theory replicate all of the functionallity. However, it will be very difficult to replicate animating transitions. Another thing is, for some reason, drawing a single round-cornered rectange, like this:

    NSColor(red: 0.5, green: 1, blue: 1, alpha: 1).set()
    let Shape = NSBezierPath()
    let ActualY = (dirtyRect.height/2)
    let FarXOrigin = dirtyRect.width*0.75, CornerRadius = dirtyRect.width/96, Height = dirtyRect.width/20, CloseXOrigin = dirtyRect.width/4, ControlPointOffset = CornerRadius*0.552284749831, Y = ActualY+(Height/4)+CornerRadius
    Shape.move(to: NSMakePoint(FarXOrigin-CornerRadius, CGFloat(Y)))
    Shape.curve(to: NSMakePoint(FarXOrigin, CGFloat(Y)-CornerRadius), controlPoint1: NSMakePoint(FarXOrigin-CornerRadius+ControlPointOffset, CGFloat(Y)), controlPoint2: NSMakePoint(FarXOrigin, CGFloat(Y)-CornerRadius+ControlPointOffset))
    Shape.line(to: NSMakePoint(FarXOrigin, CGFloat(Y)-(CornerRadius+Height-(CornerRadius*2))))
    Shape.curve(to: NSMakePoint(FarXOrigin-CornerRadius, CGFloat(Y)-Height), controlPoint1: NSMakePoint(FarXOrigin, CGFloat(Y)-(CornerRadius+Height-(CornerRadius*2)+ControlPointOffset)), controlPoint2: NSMakePoint(FarXOrigin-CornerRadius+ControlPointOffset, CGFloat(Y)-Height))
    Shape.line(to: NSMakePoint(CloseXOrigin+CornerRadius, CGFloat(Y)-Height))
    Shape.curve(to: NSMakePoint(CloseXOrigin, CGFloat(Y)-(CornerRadius+Height-(CornerRadius*2))), controlPoint1: NSMakePoint(CloseXOrigin+CornerRadius-ControlPointOffset, CGFloat(Y)-Height), controlPoint2: NSMakePoint(CloseXOrigin, CGFloat(Y)-(CornerRadius+Height-(CornerRadius*2)+ControlPointOffset)))
    Shape.line(to: NSMakePoint(CloseXOrigin, CGFloat(Y)-CornerRadius))
    Shape.curve(to: NSMakePoint(CloseXOrigin+CornerRadius, CGFloat(Y)), controlPoint1: NSMakePoint(CloseXOrigin, CGFloat(Y)-CornerRadius+ControlPointOffset), controlPoint2: NSMakePoint(CloseXOrigin+CornerRadius-ControlPointOffset, CGFloat(Y)))
    Shape.close()
    Shape.fill()

takes up a LOT more memory than calling RoundedRectangle() multiple times in SwiftUI. Also the edges in the SwiftUI round rectangle look sharp, and when drawing in an NSView, the edges look slightly less well defined. I want a backwards-compatible framework that can do custom drawing efficiently, and that I do not have to recreate too many features. What should I do? How would I create a very lightweight user interface with all the features that SwiftUI can do?

1
  • 1
    All right, read this. If you answer the question, you will be rewarded by the bounty amount MULTIPLE TIMES, because EVERY TIME I gain 100 reputation on this site, I will start a bounty to award existing answer.
    – user65481
    Mar 22, 2020 at 18:37

2 Answers 2

1

I decided to settle with apple's Metal framework. It seems to be the only framework capable of doing specific tasks that I need done, such as 3d graphics. It was pretty naive of me to assume SwiftUI could do 3d graphics.

0
0
+100

Xamarin.Mac maybe? You can use it for the development of native Mac apps with .NET and use the same macOS APIs that are used when developing in Swift. It also integrates with Xcode so you can use Xcode's Interface Builder to create interfaces

See https://visualstudio.microsoft.com/vs/mac/xamarin/

1
  • 1
    If you add links, it makes your answer much more convenient.
    – Eric S
    Mar 28, 2020 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.