How to draw graphic objects within drawRect at different times?

前端 未结 2 1862
轮回少年
轮回少年 2021-01-27 17:21

For a particular controller class, I need to draw a grid (the grid refers to a daily schedule, which changes each day, sometimes each hour.). Some time later, upon an action by

2条回答
  •  难免孤独
    2021-01-27 18:11

    It sounds to me like you'll want to separate out the drawing code for the grid from the drawing code for the schedule data.

    The easiest way to do this is to create a subclass of NSView for your schedule data- then you can create an instance of that object for each piece of data. Your grid view can position those schedule data objects by setting their frame and the schedule data objects can draw themselves in their own drawRect: method.

提交回复
热议问题