Monkey original, welcome reprint. Reproduced please specify: Reproduced from COCOS2DER-CSDN, thank you!
Original address: http://blog.csdn.net/cocos2der/article/details/52075418
Using swift how to develop a MacOS status bar app, the previous one has been told. Inside I forgot to mention how to modify the status icon for the pie-type progress. For example, when the app is dealing with something, it can add progress status to prompt the user. As shown in the following:
/// Show status bar Menu pie type Progress PrivateFuncshowstatusitemprogress() {if Letbutton = Statusitem.button {//Fixme:it works, but obviously not good.Button.subviews.removeAll ()}if Letbutton = Statusitem.button {//Fixme:it works, but obviously not good. Letframe = Nsrect (x:6Y:2, Width: -, Height: -) LetProgressindicator = Nsprogressindicator (frame:frame) Progressindicator.style =. Spinningstyle progressindicator.indeterminate =falseProgressindicator.minvalue =0Progressindicator.maxvalue = -Progressindicator.doublevalue =0Self.progressindicator = Progressindicator//When the progress is added, found that the status bar frame size is wrong, did not find a solution, but fill a picture can solve the problem of size errorStatusitem.image = Nsimage (named:"Emptyicon") Statusitem.image?. Template =trueButton.addsubview (Progressindicator)}}
Please note that
-we have added a nsprogressindicator to the Nsstatusitem button view, do not add to the view view, if added to the view, view will block the status bar click event, This way the Nsstatusitem will not respond to user clicks. (Of course, if your app does not need user clicks, you can do so)
-You should have noticed, I put a transparent picture in Nsstatusitem's image, because it is to solve the problem of frame size error
Of course, if you know how to fix it, you can tell me. Ha ha.
MacOS Menu status bar app to add pie-type Progress