Why not just move out, or do you expect to stay in the apartment rent-free?
If you have a lease, you are obliged to satisfy the conditions of that lease, which should include paying your monthly rent.
If the apartment is in foreclosure, it doesn't mean it's already bank-owned. Rather, the owner may be looking for ways to resolve his financial predicament through forbearance, loan modification, reinstatement, etc. If his tenants stop paying him rent, he'll be in worse financial shape.
If he is trying to do a short sale, he will want to show the property to prospective buyers. And he will need to provide financial statements regarding the income generated by the property. If you aren't paying your rent, he has every right to start eviction against you.
Unless you know the complete details of the pre- or actual foreclosure, how can you withhold rent?
If it is sold, and you don't have a lease, the new owner may not be bound by any agreement to keep you on at your current rate either and may give you notice to vacate, or increase in rent.