MacOS Menu status bar app to add pie-type Progress

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.